DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30973>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30973

[email] [patch] HTML email with plain text alternative and attachments

           Summary: [email] [patch] HTML email with plain text alternative
                    and attachments
           Product: Commons
           Version: Nightly Builds
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Sandbox
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


With the current MultiPartEmail class, you currently cannot properly create a
message that contains an html part, a text alternative, and attachments. The
current HtmlEmail will not properly create such a message either. The attached
patch to MultiPartEmail allows you to do this, e.g.:
MultiPartEmail email = new MultiPartEmail();
email.setFrom("[EMAIL PROTECTED]");
email.addTo("[EMAIL PROTECTED]");
email.setSubject("message subject");
email.setSubType("mixed");

MimeMultipart multiPart = new MimeMultipart("alternative");

// text alternative
MimeBodyPart bodyPart1 = new MimeBodyPart();
bodyPart1.setContent("Text message", "text/plain");
multiPart.addBodyPart(bodyPart1);

// html alternative
MimeBodyPart bodyPart2 = new MimeBodyPart();
bodyPart2.setContent("<html><body><p>html message</p></body></html>", "text/html");
multiPart.addBodyPart(bodyPart2);

email.addPart(multiPart);
// add attachments
email.send()

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to