Solved

Sending email attachments directly via InputStream from Javamail

Posted on 2004-04-18
3
2,198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

617 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