Question

I've got a mailer daemon that check a box and fetch the mails inside every X mins. When an error occurs, I need to send a alert mail, with the faulty message as an attachment.

I dont want to create a file, write the content from the original message and then add the file to the error message, I want to directly set the MimeBodyPart content from the original stream. I already did this some years ago, so I know it's possible, I just can't remember the exact syntax to copy the message stream to the MimeBodyPart and set the content type ( which is RFC2822 )

Anyone can help ?

Was it helpful?

Solution

Here's the solution that I found:

 MimeBodyPart mbp = new MimeBodyPart();
 mbp.setContent(forwardedMsg, "message/rfc822");
 mp.addPart(mbp);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top