Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to : mail attached file store in binary format in database

843830May 16 2007 — edited Mar 23 2008
how to attached mail with file that store in binary format in database ??


the code below is attached thru the browse button with the file path
because the attachment is store in binary format, how do i modify my code to get the mail attached with the attachement

File Name : [ C:\README.txt ] BROWSE


if (hasAttachment) {
// avoid the case with no text parts
MimeBodyPart bodyPart = new MimeBodyPart();
bodyPart.setContent("Attachment enclosed.", "text/plain");
mp.addBodyPart(bodyPart);
// the part with the file
FileDataSource fds =
new FileDataSource(bean.getAttachedFileName());
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
DataHandler dh = new DataHandler(fds);
attachmentBodyPart.setDataHandler(dh);
attachmentBodyPart.setFileName(fds.getName());
mp.addBodyPart(attachmentBodyPart);
}
msg.setContent(mp);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 20 2008
Added on May 16 2007
7 comments
452 views