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.
Created May 4, 2012
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(); mbp.setText(aText); mmp.addBodyPart(mbp); // Second Part: Attachments MimeBodyPart mbp2 = new MimeBodyPart(); // mimetype as forwarded attachment mbp2.setContent(aMsg, "message/rfc822"); mmp.addBodyPart(mbp2); ======================================