commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Stadler (JIRA)" <j...@apache.org>
Subject [jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails
Date Fri, 14 May 2010 06:22:44 GMT

    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12867421#action_12867421
] 

Dominik Stadler commented on EMAIL-92:
--------------------------------------

Hi Siegfried, the latest attachment contains a full patch with a small addition to have <script>-elements
also included and a helper method to extract all images from html without sending an email.


There are also test-cases included that cover the class. One of the cases verifies that you
can use something like <IMG SRC="images/somepict.png"/> in the HTML, you only need to
pass the correct "base directory" for this to work, i.e. the parent directory of the "images"
directory in this case as the code combines the specified base-directory and the image-src
when looking for the files.

> Improve support to embed images in HTML eMails
> ----------------------------------------------
>
>                 Key: EMAIL-92
>                 URL: https://issues.apache.org/jira/browse/EMAIL-92
>             Project: Commons Email
>          Issue Type: New Feature
>            Reporter: Dominik Stadler
>            Assignee: Siegfried Goeschl
>         Attachments: EMAIL-92-with-test.patch, ImageHtmlEmail.java, ImageHtmlEmail.java
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message