Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2305
  • Last Modified:

Sending email attachments directly via InputStream from Javamail

Hi,

Currently, I am making use of the Javamail api to send out mails with attachments.  It is currently implemented by initialising the DataSource to FileDataSource.  However, for this to work, a physical file must exist in the system.  

I was wondering if there is any way in which we can attach the attachments directly from an InputStream.    

Currently, the code we use to attach the attachment is:

      messageBodyPart = new MimeBodyPart();
      DataSource source = new FileDataSource(attachmentFiles[i]);
      messageBodyPart.setDataHandler(new DataHandler(source));
      messageBodyPart.setFileName(attachmentFileNames[i]);
      multipart.addBodyPart(messageBodyPart);
0
eng80327
Asked:
eng80327
1 Solution
 
objectsCommented:
Write you own DataSource implementation to wrap a stream.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now