Solved

Sending email attachments directly via InputStream from Javamail

Posted on 2004-04-18
3
2,146 Views
Last Modified: 2013-11-24
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
Comment
Question by:eng80327
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 75 total points
ID: 10855400
Write you own DataSource implementation to wrap a stream.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
check java version using powershell 13 306
ejb stateless example 2 44
collection output issue 9 66
running on tomcat not jboss eap 7.0 3 33
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question