How do I create two MimeMessage objects and attach the second MimeMessage to the first MimeMessage? When the mail is received the mail should have an attached email. The attached email should contain "from,to, subject, content" of the 2nd MimeMessage.

Benjamin Chi

See code below. The significant part is using the header "message/rfc822" and passing the Message object to the setContent() method:

MultiBodyPart.setContent(Message, "message/rfc822");

=========== Code Example. ===============
Message aMsg = // Populate this Message obj.
MimeMultipart mmp = new MimeMultipart();

// First part: Contents
MimeBodyPart mbp = new MimeBodyPart();

// Second Part: Attachments
MimeBodyPart mbp2 = new MimeBodyPart();
// mimetype as forwarded attachment
mbp2.setContent(aMsg, "message/rfc822");  
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact