commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r377151 - /jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java
Date Sun, 12 Feb 2006 11:11:29 GMT
Author: dion
Date: Sun Feb 12 03:11:26 2006
New Revision: 377151

URL: http://svn.apache.org/viewcvs?rev=377151&view=rev
Log:
Bug: 37902
Added extra embed(String,String) method as a wrapper to embed(URL,String)

Modified:
    jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java

Modified: jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java?rev=377151&r1=377150&r2=377151&view=diff
==============================================================================
--- jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java (original)
+++ jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java Sun
Feb 12 03:11:26 2006
@@ -17,6 +17,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -146,6 +147,23 @@
 
     /**
      * Embeds an URL in the HTML.
+     * @see #embed(URL, String)
+     * @since 1.1
+     */
+    public String embed(String url, String name) throws EmailException
+    {
+    	try
+    	{
+    		return embed(new URL(url), name);
+    	}
+    	catch (MalformedURLException e)
+    	{
+    		throw new EmailException("Invalid URL", e);
+    	}
+    }
+    
+    /**
+     * Embeds an URL in the HTML.
      *
      * <p>This method allows to embed a file located by an URL into
      * the mail body.  It allows, for instance, to add inline images
@@ -156,7 +174,7 @@
      * <p>Example of use:<br><code><pre>
      * HtmlEmail he = new HtmlEmail();
      * he.setHtmlMsg("&lt;html&gt;&lt;img src=cid:" +
-     *  embed("file:/my/image.gif","image.gif") +
+     *  embed(new URL("file:/my/image.gif"),"image.gif") +
      *  "&gt;&lt;/html&gt;");
      * // code to set the others email fields (not shown)
      * </pre></code>
@@ -179,7 +197,7 @@
         }
         catch (IOException e)
         {
-            throw new EmailException("Invalid URL");
+            throw new EmailException("Invalid URL", e);
         }
 
         MimeBodyPart mbp = new MimeBodyPart();



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message