Commons Email
  1. Commons Email
  2. EMAIL-23

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      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("me@mydomain.com");
      email.addTo("you@yourdomain.com");
      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()

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Scott
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development