You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2006/02/12 12:11:29 UTC
svn commit: r377151 -
/jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/HtmlEmail.java
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("<html><img src=cid:" +
- * embed("file:/my/image.gif","image.gif") +
+ * embed(new URL("file:/my/image.gif"),"image.gif") +
* "></html>");
* // 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