Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaMail Attachment from byte[]

843834Aug 12 2010 — edited Aug 13 2010
Hey!

For my internship I have implemented a Jilter for a Sendmail Mailserver. In this Jilter I have to save messages and there it is only possible to get the body of an e-mail in form on a ByteBuffer.
And for the fact that I have to store some e-mail messages I only save the body as byte[] into my database.

In some cases I have to use these messages again in my online application. Here I build a new e-mail with the existing sources from database.(Subject, Body, Recipient, Sender,...). I build these new messages with JavaMail and then send them. (This whole project is kind of a filter, where you can specifiy who is allowed to send you messages and who's not. And it should be possible to unblock messages afterwards so that you will receive them, altough they've been blocked)

My whole Application works fine if there's only text in the e-mail that should be unblocked. If there are some attachments (except from *.txt) I've the problem that the attachments are represented in textform.

So how can I manage to construct a new Message with JavaMail from my existing sources (the body as a byte[]) where everything works fine with the attachments and where they are displayed normally (in files)? Is it even possible to construct this from only a byte[]?

I've read some Javadoc i.e. Mime MultiPart stuff etc but there I've to add the files one after another.... But I only have my byte[]. And the only thing I'm able to save from the Jilter is the Content-Type. So I know if I've attachments in my message or not, but I don't know how much attachments and what type of.

Has anybody an idea to solve this problem?

Kind regards,

Sandra
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 10 2010
Added on Aug 12 2010
3 comments
1,233 views