You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dominik Stadler (JIRA)" <ji...@apache.org> on 2010/01/09 00:14:54 UTC

[jira] Created: (EMAIL-92) Improve support to embed images in HTML eMails

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


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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12886267#action_12886267 ] 

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

Some items that I found: 

- Currently you only replace img-tags under the following condition:      
{code} 
if(!this.inlineEmbeds.containsKey(imageDataSource.getName()))
{code} 

what if the same image is included in the HTML multiple times? With this check it would only be replaced once and then not any more? It seems the embed() call performs this check internally as well and returns the same cid for existing images, so it would be save to call embed() with every DataSource that we find.

- I enhanced the regex slightly to cover cases that we handled incorrectly before, the full regex is now:
    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";

The Following addition to the regex-test verifies that the regex is working with the newly discovered cases:

{code}
		// had a problem with multiple img-source tags
		matcher = pattern
				.matcher("<img src=\"file1\"/><img src=\"file2\"/>");
		assertTrue(matcher.find());
		assertEquals("file1", matcher.group(2));
		assertTrue(matcher.find());
		assertEquals("file2", matcher.group(2));

		matcher = pattern
				.matcher("<img src=\"file1\"/><img src=\"file2\"/><img src=\"file3\"/><img src=\"file4\"/><img src=\"file5\"/>");
		assertTrue(matcher.find());
		assertEquals("file1", matcher.group(2));
		assertTrue(matcher.find());
		assertEquals("file2", matcher.group(2));
		assertTrue(matcher.find());
		assertEquals("file3", matcher.group(2));
		assertTrue(matcher.find());
		assertEquals("file4", matcher.group(2));
		assertTrue(matcher.find());
		assertEquals("file5", matcher.group(2));

		// try with invalid HTML that is seens sometimes, i.e. without closing "/" or "</img>"
		matcher = pattern
				.matcher("<img src=\"file1\"><img src=\"file2\">");
		assertTrue(matcher.find());
		assertEquals("file1", matcher.group(2));
		assertTrue(matcher.find());
		assertEquals("file2", matcher.group(2));
{code}


> 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.


[jira] Issue Comment Edited: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887645#action_12887645 ] 

Dominik Stadler edited comment on EMAIL-92 at 7/13/10 12:07 AM:
----------------------------------------------------------------

Looks better now. Here another small patch, it seems the regex was corrupted with the last checkin, there is now a "\\" missing in front of "s":

{code}
### Eclipse Workspace Patch 1.0
#P commons-email-trunk
Index: src/java/org/apache/commons/mail/ImageHtmlEmail.java
===================================================================
--- src/java/org/apache/commons/mail/ImageHtmlEmail.java	(revision 963592)
+++ src/java/org/apache/commons/mail/ImageHtmlEmail.java	(working copy)
@@ -54,11 +55,11 @@
      * newlines on any place, HTML is not case sensitive and there can be
      * arbitrary text between "IMG" and "SRC" like IDs and other things.
      */
-    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=s*[\"'])([^\"']+?)([\"'])";
+    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
     public static final String REGEX_SCRIPT_SRC = "(<[Ss][Cc][Rr][Ii][Pp][Tt]\\s*.*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
-    // this pattern looks for the HTML imgage tag which indicates embedded images,
+    // this pattern looks for the HTML image tag which indicates embedded images,
     // the grouping is necessary to allow to replace the element with the CID
     protected static final Pattern pattern = Pattern.compile(REGEX_IMG_SRC);
 {code}

      was (Author: dominik.stadler@gmx.at):
    Looks better now. Here another small patch, it seems the regex was corrupted with the last checkin, there is now a "\\" missing in front of "s":

### Eclipse Workspace Patch 1.0
#P commons-email-trunk
Index: src/java/org/apache/commons/mail/ImageHtmlEmail.java
===================================================================
--- src/java/org/apache/commons/mail/ImageHtmlEmail.java	(revision 963592)
+++ src/java/org/apache/commons/mail/ImageHtmlEmail.java	(working copy)
@@ -54,11 +55,11 @@
      * newlines on any place, HTML is not case sensitive and there can be
      * arbitrary text between "IMG" and "SRC" like IDs and other things.
      */
-    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=s*[\"'])([^\"']+?)([\"'])";
+    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
     public static final String REGEX_SCRIPT_SRC = "(<[Ss][Cc][Rr][Ii][Pp][Tt]\\s*.*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
-    // this pattern looks for the HTML imgage tag which indicates embedded images,
+    // this pattern looks for the HTML image tag which indicates embedded images,
     // the grouping is necessary to allow to replace the element with the CID
     protected static final Pattern pattern = Pattern.compile(REGEX_IMG_SRC);
 

  
> 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12886026#action_12886026 ] 

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

you are right about &amp;, it needs to be decoded when we read the src-tag, I will look into ways to do general HTML decoding at that point

for URL, this would reqiure an additional parameter for baseURL to allow us to construct a valid URL here as the HTML only contains a relative adress here. We should probably put this into a second method to have the possibility to provide it or not.

> 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887465#action_12887465 ] 

Siegfried Goeschl commented on EMAIL-92:
----------------------------------------

Fixed the replacement of identical image resources

> 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12886071#action_12886071 ] 

Siegfried Goeschl commented on EMAIL-92:
----------------------------------------

I nearly finished my work on your code - I leave a quick note when I commit my changes. Have a look at it if everything is fine and hopefully I did not break your usecases


> 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.


[jira] Issue Comment Edited: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887645#action_12887645 ] 

Dominik Stadler edited comment on EMAIL-92 at 7/13/10 12:08 AM:
----------------------------------------------------------------

Looks better now. Here another small patch, it seems the regex was corrupted with the last checkin, there is now a backslash missing in front of "s":

{code}
### Eclipse Workspace Patch 1.0
#P commons-email-trunk
Index: src/java/org/apache/commons/mail/ImageHtmlEmail.java
===================================================================
--- src/java/org/apache/commons/mail/ImageHtmlEmail.java	(revision 963592)
+++ src/java/org/apache/commons/mail/ImageHtmlEmail.java	(working copy)
@@ -54,11 +55,11 @@
      * newlines on any place, HTML is not case sensitive and there can be
      * arbitrary text between "IMG" and "SRC" like IDs and other things.
      */
-    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=s*[\"'])([^\"']+?)([\"'])";
+    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
     public static final String REGEX_SCRIPT_SRC = "(<[Ss][Cc][Rr][Ii][Pp][Tt]\\s*.*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
-    // this pattern looks for the HTML imgage tag which indicates embedded images,
+    // this pattern looks for the HTML image tag which indicates embedded images,
     // the grouping is necessary to allow to replace the element with the CID
     protected static final Pattern pattern = Pattern.compile(REGEX_IMG_SRC);
 {code}

      was (Author: dominik.stadler@gmx.at):
    Looks better now. Here another small patch, it seems the regex was corrupted with the last checkin, there is now a "\\" missing in front of "s":

{code}
### Eclipse Workspace Patch 1.0
#P commons-email-trunk
Index: src/java/org/apache/commons/mail/ImageHtmlEmail.java
===================================================================
--- src/java/org/apache/commons/mail/ImageHtmlEmail.java	(revision 963592)
+++ src/java/org/apache/commons/mail/ImageHtmlEmail.java	(working copy)
@@ -54,11 +55,11 @@
      * newlines on any place, HTML is not case sensitive and there can be
      * arbitrary text between "IMG" and "SRC" like IDs and other things.
      */
-    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=s*[\"'])([^\"']+?)([\"'])";
+    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
     public static final String REGEX_SCRIPT_SRC = "(<[Ss][Cc][Rr][Ii][Pp][Tt]\\s*.*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
-    // this pattern looks for the HTML imgage tag which indicates embedded images,
+    // this pattern looks for the HTML image tag which indicates embedded images,
     // the grouping is necessary to allow to replace the element with the CID
     protected static final Pattern pattern = Pattern.compile(REGEX_IMG_SRC);
 {code}
  
> 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12867263#action_12867263 ] 

Siegfried Goeschl commented on EMAIL-92:
----------------------------------------

Is there a way to embed relative referenced images , e.g. <img src="images/logo.png" alt="" /> - as far as I understand it the code does not pick up those images ... 

Siegfried Goeschl

> 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: 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12884921#action_12884921 ] 

Siegfried Goeschl commented on EMAIL-92:
----------------------------------------

I wrote a few additional tests to check if I can easily create an email from my Sonar installation which is currently not possible

Here the image markup from http://nemo.sonarsource.org/project/index/51834

"<img alt=\"Chart?ck=xradar&amp;w=120&amp;h=120&amp;c=7fff00|7fff00&amp;m=4&amp;g=0\" src=\"/chart ck=xradar&amp;w=120&amp;h=120&amp;c=7fff00|7fff00&amp;m=4&amp;g=0.2&amp;l=A,C,S,T&amp;v=3.0,3.0,2.0,2.0\"");

which should result in the following URL

http://nemo.sonarsource.org/chart?ck=xradar&w=120&h=120&c=7fff00|7fff00&m=4&g=0.2&l=A,C,S,T&v=3.0,3.0,2.0,2.0

but throws the following exception

SEVERE: Could not download URL: /chart?ck=xradar&amp;w=120&amp;h=120&amp;c=7fff00|7fff00&amp;m=4&amp;g=0.2&amp;l=A,C,S,T&amp;v=3.0,3.0,2.0,2.0 Exception: no protocol: /chart?ck=xradar&amp;w=120&amp;h=120&amp;c=7fff00|7fff00&amp;m=4&amp;g=0.2&amp;l=A,C,S,T&amp;v=3.0,3.0,2.0,2.0

Basically I see two problems

+) creating the correct URL
+) resolve the "&amp"

Can you get in touch with me since I'm working on a modified code base (I will attach it as patch)

> 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887708#action_12887708 ] 

Siegfried Goeschl commented on EMAIL-92:
----------------------------------------

I applied the patch and this patch also fixed a broken test (which was commented out) - looks good to me ... :-)

> 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.


[jira] Resolved: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Siegfried Goeschl resolved EMAIL-92.
------------------------------------

    Resolution: Fixed

Is now part of commons-email

> 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
>             Fix For: 1.3
>
>         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.


[jira] Updated: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dominik Stadler updated EMAIL-92:
---------------------------------

    Attachment: ImageHtmlEmail.java

During testing I found some instances of urls that were not catched correctly because the regular expression was not taking more cases into account, it also did not behave nicely on empty input html. The attached updated version fixes these two issues.

> 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
>         Attachments: 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.


[jira] Updated: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Siegfried Goeschl updated EMAIL-92:
-----------------------------------

    Fix Version/s: 1.3

> 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
>             Fix For: 1.3
>
>         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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887645#action_12887645 ] 

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

Looks better now. Here another small patch, it seems the regex was corrupted with the last checkin, there is now a "\\" missing in front of "s":

### Eclipse Workspace Patch 1.0
#P commons-email-trunk
Index: src/java/org/apache/commons/mail/ImageHtmlEmail.java
===================================================================
--- src/java/org/apache/commons/mail/ImageHtmlEmail.java	(revision 963592)
+++ src/java/org/apache/commons/mail/ImageHtmlEmail.java	(working copy)
@@ -54,11 +55,11 @@
      * newlines on any place, HTML is not case sensitive and there can be
      * arbitrary text between "IMG" and "SRC" like IDs and other things.
      */
-    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=s*[\"'])([^\"']+?)([\"'])";
+    public static final String REGEX_IMG_SRC = "(<[Ii][Mm][Gg]\\s*[^>]*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
     public static final String REGEX_SCRIPT_SRC = "(<[Ss][Cc][Rr][Ii][Pp][Tt]\\s*.*?\\s+[Ss][Rr][Cc]\\s*=\\s*[\"'])([^\"']+?)([\"'])";
 
-    // this pattern looks for the HTML imgage tag which indicates embedded images,
+    // this pattern looks for the HTML image tag which indicates embedded images,
     // the grouping is necessary to allow to replace the element with the CID
     protected static final Pattern pattern = Pattern.compile(REGEX_IMG_SRC);
 


> 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.


[jira] Updated: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dominik Stadler updated EMAIL-92:
---------------------------------

    Attachment: EMAIL-92-with-test.patch

- updated code for ImageHtmlEmail.java, we now also support adding script-elements in addition to image-files.
- added full unit test case

this is a patch that applies against the latest commons-email from trunk, only thing missing is updating maven build script as I used an eclipse project for building/executing.

> 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12886126#action_12886126 ] 

Siegfried Goeschl commented on EMAIL-92:
----------------------------------------

Added the reworked contribution to SVN.

> 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12867248#action_12867248 ] 

Siegfried Goeschl commented on EMAIL-92:
----------------------------------------

Hi Dominik,

do you have any regression tests for the code?

Siegfried Goeschl

> 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: 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.


[jira] Updated: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Dominik Stadler (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dominik Stadler updated EMAIL-92:
---------------------------------

    Attachment: ImageHtmlEmail.java

New class ImageHtmlEmail to automatically embed images from HTML emails.

> 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
>         Attachments: 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.


[jira] Commented: (EMAIL-92) Improve support to embed images in HTML eMails

Posted by "Siegfried Goeschl (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/EMAIL-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12886465#action_12886465 ] 

Siegfried Goeschl commented on EMAIL-92:
----------------------------------------

I have a look at it ...

> 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.