Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sending email attachments directly via InputStream from Javamail

Posted on 2004-04-18
3
Medium Priority
?
2,260 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 300 total points
ID: 10855400
Write you own DataSource implementation to wrap a stream.
0

Featured Post

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

688 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