Commons Email
  1. Commons Email
  2. EMAIL-92

Improve support to embed images in HTML eMails

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3
    • Labels:
      None

      Description

      I have created a improvement on top of HtmlEmail class which automatically detects <img src=".."/> tags in the HTML source and which embeds all the URLs correctly in the email so they are sent as attachments as part of the email.

      It is implemented as new class ImageHtmlEmail, no existing code of commons email is touched at all.

      This make sending HTML Mails much easier, now it is as simple as

      ImageHtmlEmail email = new ImageHtmlEmail();
      email.setHostName(SMTP_HOST);
      email.addTo(EMAIL_TO, "DS");
      email.setFrom(EMAIL_FROM, "Me");
      email.setSubject(EMAIL_SUBJECT);

      String html = FileUtils.readFileToString(new File("/tmp/test_email.html"));

      // set the html message
      email.setHtmlMsg(html, new File("/tmp"));

      // set the alternative message
      email.setTextMsg("Your email client does not support HTML messages");

      // send the email
      email.send();

      as stated in the mail, I am making this availalbe under the Apache License 2.0 so that it can be integrated if it sounds useful.

      1. EMAIL-92-with-test.patch
        41 kB
        Dominik Stadler
      2. ImageHtmlEmail.java
        4 kB
        Dominik Stadler
      3. ImageHtmlEmail.java
        4 kB
        Dominik Stadler

        Activity

        Dominik Stadler created issue -
        Dominik Stadler made changes -
        Field Original Value New Value
        Attachment ImageHtmlEmail.java [ 12429796 ]
        Dominik Stadler made changes -
        Attachment ImageHtmlEmail.java [ 12429818 ]
        Siegfried Goeschl made changes -
        Assignee Siegfried Goeschl [ sgoeschl ]
        Siegfried Goeschl made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Dominik Stadler made changes -
        Attachment EMAIL-92-with-test.patch [ 12444472 ]
        Siegfried Goeschl made changes -
        Fix Version/s 1.3 [ 12315052 ]
        Siegfried Goeschl made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Thomas Neidhart made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Siegfried Goeschl
            Reporter:
            Dominik Stadler
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development