Saturday, February 2, 2002 08:52 AM
I have finished like this, the client can choose the file to be the attachment from their machine,
and then my program send the mail with the attachment without save it on server size file system.
1. use the request.getInputStream() in your servlet,
and parse the data to get the necessary infomation of the upload file
like filename, file data(bytes), content type ..etc.
2. follow the send mail with attachments step, constructs a new mail, but in attachment step
use the ByteArrayDataSource (you can find this in java mail's example)
you have a upload file as attachment, with the following data
byte content = ...;
String filename = ...;
String content_type = ....;
MimeBodyPart mbp = new MimeBodyPart();
ByteArrayDataSource ds = new ByteArrayDataSource(content, content_type);
then you have finished an attachment of the mail.