Solved

Sending email attachments directly via InputStream from Javamail

Posted on 2004-04-18
3
2,063 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
Comment Utility
Write you own DataSource implementation to wrap a stream.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars challenge 6 62
basic hardware to learn oop advanced design patterns 3 71
stringclean challenge 26 53
strDist challenge 35 83
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now