开发者

How to add a message as an attachment on another message with javax.mail

开发者 https://www.devze.com 2023-01-09 07:26 出处:网络
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'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);
0

精彩评论

暂无评论...
验证码 换一张
取 消