Uploaded image for project: 'Commons Email'
  1. Commons Email
  2. EMAIL-23

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • Operating System: other
      Platform: Other

    • 30973

    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()

      Attachments

        Activity

          People

            Unassigned Unassigned
            scott@minutestopost.com Scott
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: