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 开发者_StackOverflowwant 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 ?
Here's the solution that I found:
MimeBodyPart mbp = new MimeBodyPart();
mbp.setContent(forwardedMsg, "message/rfc822");
mp.addPart(mbp);
精彩评论