commons-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r952406 [39/42] - in /websites/production/commons/content/proper/commons-email: ./ apidocs/ apidocs/org/apache/commons/mail/ apidocs/org/apache/commons/mail/class-use/ apidocs/org/apache/commons/mail/resolver/ apidocs/org/apache/commons/mai...
Date Sat, 23 May 2015 06:51:00 GMT
Modified: websites/production/commons/content/proper/commons-email/xref/org/apache/commons/mail/HtmlEmail.html
==============================================================================
--- websites/production/commons/content/proper/commons-email/xref/org/apache/commons/mail/HtmlEmail.html (original)
+++ websites/production/commons/content/proper/commons-email/xref/org/apache/commons/mail/HtmlEmail.html Sat May 23 06:50:57 2015
@@ -88,7 +88,7 @@
 <a class="jxr_linenumber" name="L80" href="#L80">80</a>  <em class="jxr_javadoccomment"> * method defined on the &lt;code&gt;DataSource&lt;/code&gt;s to make the determination.</em>
 <a class="jxr_linenumber" name="L81" href="#L81">81</a>  <em class="jxr_javadoccomment"> *</em>
 <a class="jxr_linenumber" name="L82" href="#L82">82</a>  <em class="jxr_javadoccomment"> * @since 1.0</em>
-<a class="jxr_linenumber" name="L83" href="#L83">83</a>  <em class="jxr_javadoccomment"> * @version $Id: HtmlEmail.java 1606709 2014-06-30 12:26:06Z ggregory $</em>
+<a class="jxr_linenumber" name="L83" href="#L83">83</a>  <em class="jxr_javadoccomment"> * @version $Id: HtmlEmail.java 1647983 2014-12-26 14:25:27Z tn $</em>
 <a class="jxr_linenumber" name="L84" href="#L84">84</a>  <em class="jxr_javadoccomment"> */</em>
 <a class="jxr_linenumber" name="L85" href="#L85">85</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">HtmlEmail</a> <strong class="jxr_keyword">extends</strong> <a href="../../../../org/apache/commons/mail/MultiPartEmail.html">MultiPartEmail</a>
 <a class="jxr_linenumber" name="L86" href="#L86">86</a>  {
@@ -282,423 +282,448 @@
 <a class="jxr_linenumber" name="L274" href="#L274">274</a>             {
 <a class="jxr_linenumber" name="L275" href="#L275">275</a>                 <strong class="jxr_keyword">return</strong> ii.getCid();
 <a class="jxr_linenumber" name="L276" href="#L276">276</a>             }
-<a class="jxr_linenumber" name="L277" href="#L277">277</a>             <strong class="jxr_keyword">else</strong>
-<a class="jxr_linenumber" name="L278" href="#L278">278</a>             {
-<a class="jxr_linenumber" name="L279" href="#L279">279</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"embedded name '"</span> + name
-<a class="jxr_linenumber" name="L280" href="#L280">280</a>                     + <span class="jxr_string">"' is already bound to URL "</span> + urlDataSource.getURL()
-<a class="jxr_linenumber" name="L281" href="#L281">281</a>                     + <span class="jxr_string">"; existing names cannot be rebound"</span>);
-<a class="jxr_linenumber" name="L282" href="#L282">282</a>             }
-<a class="jxr_linenumber" name="L283" href="#L283">283</a>         }
-<a class="jxr_linenumber" name="L284" href="#L284">284</a> 
-<a class="jxr_linenumber" name="L285" href="#L285">285</a>         <em class="jxr_comment">// verify that the URL is valid</em>
-<a class="jxr_linenumber" name="L286" href="#L286">286</a>         InputStream is = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="L287" href="#L287">287</a>         <strong class="jxr_keyword">try</strong>
-<a class="jxr_linenumber" name="L288" href="#L288">288</a>         {
-<a class="jxr_linenumber" name="L289" href="#L289">289</a>             is = url.openStream();
-<a class="jxr_linenumber" name="L290" href="#L290">290</a>         }
-<a class="jxr_linenumber" name="L291" href="#L291">291</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> IOException e)
-<a class="jxr_linenumber" name="L292" href="#L292">292</a>         {
-<a class="jxr_linenumber" name="L293" href="#L293">293</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"Invalid URL"</span>, e);
-<a class="jxr_linenumber" name="L294" href="#L294">294</a>         }
-<a class="jxr_linenumber" name="L295" href="#L295">295</a>         <strong class="jxr_keyword">finally</strong>
-<a class="jxr_linenumber" name="L296" href="#L296">296</a>         {
-<a class="jxr_linenumber" name="L297" href="#L297">297</a>             <strong class="jxr_keyword">try</strong>
-<a class="jxr_linenumber" name="L298" href="#L298">298</a>             {
-<a class="jxr_linenumber" name="L299" href="#L299">299</a>                 <strong class="jxr_keyword">if</strong> (is != <strong class="jxr_keyword">null</strong>)
-<a class="jxr_linenumber" name="L300" href="#L300">300</a>                 {
-<a class="jxr_linenumber" name="L301" href="#L301">301</a>                     is.close();
-<a class="jxr_linenumber" name="L302" href="#L302">302</a>                 }
-<a class="jxr_linenumber" name="L303" href="#L303">303</a>             }
-<a class="jxr_linenumber" name="L304" href="#L304">304</a>             <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> IOException ioe) <em class="jxr_comment">// NOPMD</em>
-<a class="jxr_linenumber" name="L305" href="#L305">305</a>             { <em class="jxr_comment">/* sigh */</em> }
-<a class="jxr_linenumber" name="L306" href="#L306">306</a>         }
+<a class="jxr_linenumber" name="L277" href="#L277">277</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"embedded name '"</span> + name
+<a class="jxr_linenumber" name="L278" href="#L278">278</a>                 + <span class="jxr_string">"' is already bound to URL "</span> + urlDataSource.getURL()
+<a class="jxr_linenumber" name="L279" href="#L279">279</a>                 + <span class="jxr_string">"; existing names cannot be rebound"</span>);
+<a class="jxr_linenumber" name="L280" href="#L280">280</a>         }
+<a class="jxr_linenumber" name="L281" href="#L281">281</a> 
+<a class="jxr_linenumber" name="L282" href="#L282">282</a>         <em class="jxr_comment">// verify that the URL is valid</em>
+<a class="jxr_linenumber" name="L283" href="#L283">283</a>         InputStream is = <strong class="jxr_keyword">null</strong>;
+<a class="jxr_linenumber" name="L284" href="#L284">284</a>         <strong class="jxr_keyword">try</strong>
+<a class="jxr_linenumber" name="L285" href="#L285">285</a>         {
+<a class="jxr_linenumber" name="L286" href="#L286">286</a>             is = url.openStream();
+<a class="jxr_linenumber" name="L287" href="#L287">287</a>         }
+<a class="jxr_linenumber" name="L288" href="#L288">288</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> IOException e)
+<a class="jxr_linenumber" name="L289" href="#L289">289</a>         {
+<a class="jxr_linenumber" name="L290" href="#L290">290</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"Invalid URL"</span>, e);
+<a class="jxr_linenumber" name="L291" href="#L291">291</a>         }
+<a class="jxr_linenumber" name="L292" href="#L292">292</a>         <strong class="jxr_keyword">finally</strong>
+<a class="jxr_linenumber" name="L293" href="#L293">293</a>         {
+<a class="jxr_linenumber" name="L294" href="#L294">294</a>             <strong class="jxr_keyword">try</strong>
+<a class="jxr_linenumber" name="L295" href="#L295">295</a>             {
+<a class="jxr_linenumber" name="L296" href="#L296">296</a>                 <strong class="jxr_keyword">if</strong> (is != <strong class="jxr_keyword">null</strong>)
+<a class="jxr_linenumber" name="L297" href="#L297">297</a>                 {
+<a class="jxr_linenumber" name="L298" href="#L298">298</a>                     is.close();
+<a class="jxr_linenumber" name="L299" href="#L299">299</a>                 }
+<a class="jxr_linenumber" name="L300" href="#L300">300</a>             }
+<a class="jxr_linenumber" name="L301" href="#L301">301</a>             <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> IOException ioe) <em class="jxr_comment">// NOPMD</em>
+<a class="jxr_linenumber" name="L302" href="#L302">302</a>             { <em class="jxr_comment">/* sigh */</em> }
+<a class="jxr_linenumber" name="L303" href="#L303">303</a>         }
+<a class="jxr_linenumber" name="L304" href="#L304">304</a> 
+<a class="jxr_linenumber" name="L305" href="#L305">305</a>         <strong class="jxr_keyword">return</strong> embed(<strong class="jxr_keyword">new</strong> URLDataSource(url), name);
+<a class="jxr_linenumber" name="L306" href="#L306">306</a>     }
 <a class="jxr_linenumber" name="L307" href="#L307">307</a> 
-<a class="jxr_linenumber" name="L308" href="#L308">308</a>         <strong class="jxr_keyword">return</strong> embed(<strong class="jxr_keyword">new</strong> URLDataSource(url), name);
-<a class="jxr_linenumber" name="L309" href="#L309">309</a>     }
-<a class="jxr_linenumber" name="L310" href="#L310">310</a> 
-<a class="jxr_linenumber" name="L311" href="#L311">311</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L312" href="#L312">312</a> <em class="jxr_javadoccomment">     * Embeds a file in the HTML. This implementation delegates to</em>
-<a class="jxr_linenumber" name="L313" href="#L313">313</a> <em class="jxr_javadoccomment">     * {@link #embed(File, String)}.</em>
-<a class="jxr_linenumber" name="L314" href="#L314">314</a> <em class="jxr_javadoccomment">     *</em>
-<a class="jxr_linenumber" name="L315" href="#L315">315</a> <em class="jxr_javadoccomment">     * @param file The &lt;code&gt;File&lt;/code&gt; object to embed</em>
-<a class="jxr_linenumber" name="L316" href="#L316">316</a> <em class="jxr_javadoccomment">     * @return A String with the Content-ID of the file.</em>
-<a class="jxr_linenumber" name="L317" href="#L317">317</a> <em class="jxr_javadoccomment">     * @throws EmailException when the supplied &lt;code&gt;File&lt;/code&gt; cannot be</em>
-<a class="jxr_linenumber" name="L318" href="#L318">318</a> <em class="jxr_javadoccomment">     * used; also see {@link javax.mail.internet.MimeBodyPart} for definitions</em>
-<a class="jxr_linenumber" name="L319" href="#L319">319</a> <em class="jxr_javadoccomment">     *</em>
-<a class="jxr_linenumber" name="L320" href="#L320">320</a> <em class="jxr_javadoccomment">     * @see #embed(File, String)</em>
-<a class="jxr_linenumber" name="L321" href="#L321">321</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
-<a class="jxr_linenumber" name="L322" href="#L322">322</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L323" href="#L323">323</a>     <strong class="jxr_keyword">public</strong> String embed(<strong class="jxr_keyword">final</strong> File file) <strong class="jxr_keyword">throws</strong> EmailException
-<a class="jxr_linenumber" name="L324" href="#L324">324</a>     {
-<a class="jxr_linenumber" name="L325" href="#L325">325</a>         <strong class="jxr_keyword">final</strong> String cid = EmailUtils.randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase(Locale.ENGLISH);
-<a class="jxr_linenumber" name="L326" href="#L326">326</a>         <strong class="jxr_keyword">return</strong> embed(file, cid);
-<a class="jxr_linenumber" name="L327" href="#L327">327</a>     }
-<a class="jxr_linenumber" name="L328" href="#L328">328</a> 
-<a class="jxr_linenumber" name="L329" href="#L329">329</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L330" href="#L330">330</a> <em class="jxr_javadoccomment">     * Embeds a file in the HTML.</em>
-<a class="jxr_linenumber" name="L331" href="#L331">331</a> <em class="jxr_javadoccomment">     *</em>
-<a class="jxr_linenumber" name="L332" href="#L332">332</a> <em class="jxr_javadoccomment">     * &lt;p&gt;This method embeds a file located by an URL into</em>
-<a class="jxr_linenumber" name="L333" href="#L333">333</a> <em class="jxr_javadoccomment">     * the mail body. It allows, for instance, to add inline images</em>
-<a class="jxr_linenumber" name="L334" href="#L334">334</a> <em class="jxr_javadoccomment">     * to the email.  Inline files may be referenced with a</em>
-<a class="jxr_linenumber" name="L335" href="#L335">335</a> <em class="jxr_javadoccomment">     * &lt;code&gt;cid:xxxxxx&lt;/code&gt; URL, where xxxxxx is the Content-ID</em>
-<a class="jxr_linenumber" name="L336" href="#L336">336</a> <em class="jxr_javadoccomment">     * returned by the embed function. Files are bound to their names, which is</em>
-<a class="jxr_linenumber" name="L337" href="#L337">337</a> <em class="jxr_javadoccomment">     * the value returned by {@link java.io.File#getName()}. If the same file</em>
-<a class="jxr_linenumber" name="L338" href="#L338">338</a> <em class="jxr_javadoccomment">     * is embedded multiple times, the same CID is guaranteed to be returned.</em>
-<a class="jxr_linenumber" name="L339" href="#L339">339</a> <em class="jxr_javadoccomment">     *</em>
-<a class="jxr_linenumber" name="L340" href="#L340">340</a> <em class="jxr_javadoccomment">     * &lt;p&gt;While functionally the same as passing &lt;code&gt;FileDataSource&lt;/code&gt; to</em>
-<a class="jxr_linenumber" name="L341" href="#L341">341</a> <em class="jxr_javadoccomment">     * {@link #embed(DataSource, String, String)}, this method attempts</em>
-<a class="jxr_linenumber" name="L342" href="#L342">342</a> <em class="jxr_javadoccomment">     * to validate the file before embedding it in the message and will throw</em>
-<a class="jxr_linenumber" name="L343" href="#L343">343</a> <em class="jxr_javadoccomment">     * &lt;code&gt;EmailException&lt;/code&gt; if the validation fails. In this case, the</em>
-<a class="jxr_linenumber" name="L344" href="#L344">344</a> <em class="jxr_javadoccomment">     * &lt;code&gt;HtmlEmail&lt;/code&gt; object will not be changed.</em>
-<a class="jxr_linenumber" name="L345" href="#L345">345</a> <em class="jxr_javadoccomment">     *</em>
-<a class="jxr_linenumber" name="L346" href="#L346">346</a> <em class="jxr_javadoccomment">     * @param file The &lt;code&gt;File&lt;/code&gt; to embed</em>
-<a class="jxr_linenumber" name="L347" href="#L347">347</a> <em class="jxr_javadoccomment">     * @param cid the Content-ID to use for the embedded &lt;code&gt;File&lt;/code&gt;</em>
-<a class="jxr_linenumber" name="L348" href="#L348">348</a> <em class="jxr_javadoccomment">     * @return A String with the Content-ID of the file.</em>
-<a class="jxr_linenumber" name="L349" href="#L349">349</a> <em class="jxr_javadoccomment">     * @throws EmailException when the supplied &lt;code&gt;File&lt;/code&gt; cannot be used</em>
-<a class="jxr_linenumber" name="L350" href="#L350">350</a> <em class="jxr_javadoccomment">     *  or if the file has already been embedded;</em>
-<a class="jxr_linenumber" name="L351" href="#L351">351</a> <em class="jxr_javadoccomment">     *  also see {@link javax.mail.internet.MimeBodyPart} for definitions</em>
-<a class="jxr_linenumber" name="L352" href="#L352">352</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
-<a class="jxr_linenumber" name="L353" href="#L353">353</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L354" href="#L354">354</a>     <strong class="jxr_keyword">public</strong> String embed(<strong class="jxr_keyword">final</strong> File file, <strong class="jxr_keyword">final</strong> String cid) <strong class="jxr_keyword">throws</strong> EmailException
-<a class="jxr_linenumber" name="L355" href="#L355">355</a>     {
-<a class="jxr_linenumber" name="L356" href="#L356">356</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isEmpty(file.getName()))
-<a class="jxr_linenumber" name="L357" href="#L357">357</a>         {
-<a class="jxr_linenumber" name="L358" href="#L358">358</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"file name cannot be null or empty"</span>);
-<a class="jxr_linenumber" name="L359" href="#L359">359</a>         }
-<a class="jxr_linenumber" name="L360" href="#L360">360</a> 
-<a class="jxr_linenumber" name="L361" href="#L361">361</a>         <em class="jxr_comment">// verify that the File can provide a canonical path</em>
-<a class="jxr_linenumber" name="L362" href="#L362">362</a>         String filePath = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="L363" href="#L363">363</a>         <strong class="jxr_keyword">try</strong>
-<a class="jxr_linenumber" name="L364" href="#L364">364</a>         {
-<a class="jxr_linenumber" name="L365" href="#L365">365</a>             filePath = file.getCanonicalPath();
-<a class="jxr_linenumber" name="L366" href="#L366">366</a>         }
-<a class="jxr_linenumber" name="L367" href="#L367">367</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> IOException ioe)
-<a class="jxr_linenumber" name="L368" href="#L368">368</a>         {
-<a class="jxr_linenumber" name="L369" href="#L369">369</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"couldn't get canonical path for "</span>
-<a class="jxr_linenumber" name="L370" href="#L370">370</a>                     + file.getName(), ioe);
-<a class="jxr_linenumber" name="L371" href="#L371">371</a>         }
-<a class="jxr_linenumber" name="L372" href="#L372">372</a> 
-<a class="jxr_linenumber" name="L373" href="#L373">373</a>         <em class="jxr_comment">// check if a FileDataSource for this name has already been attached;</em>
-<a class="jxr_linenumber" name="L374" href="#L374">374</a>         <em class="jxr_comment">// if so, return the cached CID value.</em>
-<a class="jxr_linenumber" name="L375" href="#L375">375</a>         <strong class="jxr_keyword">if</strong> (inlineEmbeds.containsKey(file.getName()))
-<a class="jxr_linenumber" name="L376" href="#L376">376</a>         {
-<a class="jxr_linenumber" name="L377" href="#L377">377</a>             <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a> ii = inlineEmbeds.get(file.getName());
-<a class="jxr_linenumber" name="L378" href="#L378">378</a>             <strong class="jxr_keyword">final</strong> FileDataSource fileDataSource = (FileDataSource) ii.getDataSource();
-<a class="jxr_linenumber" name="L379" href="#L379">379</a>             <em class="jxr_comment">// make sure the supplied file has the same canonical path</em>
-<a class="jxr_linenumber" name="L380" href="#L380">380</a>             <em class="jxr_comment">// as the one already associated with this name.</em>
-<a class="jxr_linenumber" name="L381" href="#L381">381</a>             String existingFilePath = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="L382" href="#L382">382</a>             <strong class="jxr_keyword">try</strong>
-<a class="jxr_linenumber" name="L383" href="#L383">383</a>             {
-<a class="jxr_linenumber" name="L384" href="#L384">384</a>                 existingFilePath = fileDataSource.getFile().getCanonicalPath();
-<a class="jxr_linenumber" name="L385" href="#L385">385</a>             }
-<a class="jxr_linenumber" name="L386" href="#L386">386</a>             <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> IOException ioe)
-<a class="jxr_linenumber" name="L387" href="#L387">387</a>             {
-<a class="jxr_linenumber" name="L388" href="#L388">388</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"couldn't get canonical path for file "</span>
-<a class="jxr_linenumber" name="L389" href="#L389">389</a>                         + fileDataSource.getFile().getName()
-<a class="jxr_linenumber" name="L390" href="#L390">390</a>                         + <span class="jxr_string">"which has already been embedded"</span>, ioe);
-<a class="jxr_linenumber" name="L391" href="#L391">391</a>             }
-<a class="jxr_linenumber" name="L392" href="#L392">392</a>             <strong class="jxr_keyword">if</strong> (filePath.equals(existingFilePath))
-<a class="jxr_linenumber" name="L393" href="#L393">393</a>             {
-<a class="jxr_linenumber" name="L394" href="#L394">394</a>                 <strong class="jxr_keyword">return</strong> ii.getCid();
-<a class="jxr_linenumber" name="L395" href="#L395">395</a>             }
-<a class="jxr_linenumber" name="L396" href="#L396">396</a>             <strong class="jxr_keyword">else</strong>
-<a class="jxr_linenumber" name="L397" href="#L397">397</a>             {
-<a class="jxr_linenumber" name="L398" href="#L398">398</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"embedded name '"</span> + file.getName()
-<a class="jxr_linenumber" name="L399" href="#L399">399</a>                     + <span class="jxr_string">"' is already bound to file "</span> + existingFilePath
-<a class="jxr_linenumber" name="L400" href="#L400">400</a>                     + <span class="jxr_string">"; existing names cannot be rebound"</span>);
-<a class="jxr_linenumber" name="L401" href="#L401">401</a>             }
+<a class="jxr_linenumber" name="L308" href="#L308">308</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L309" href="#L309">309</a> <em class="jxr_javadoccomment">     * Embeds a file in the HTML. This implementation delegates to</em>
+<a class="jxr_linenumber" name="L310" href="#L310">310</a> <em class="jxr_javadoccomment">     * {@link #embed(File, String)}.</em>
+<a class="jxr_linenumber" name="L311" href="#L311">311</a> <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L312" href="#L312">312</a> <em class="jxr_javadoccomment">     * @param file The &lt;code&gt;File&lt;/code&gt; object to embed</em>
+<a class="jxr_linenumber" name="L313" href="#L313">313</a> <em class="jxr_javadoccomment">     * @return A String with the Content-ID of the file.</em>
+<a class="jxr_linenumber" name="L314" href="#L314">314</a> <em class="jxr_javadoccomment">     * @throws EmailException when the supplied &lt;code&gt;File&lt;/code&gt; cannot be</em>
+<a class="jxr_linenumber" name="L315" href="#L315">315</a> <em class="jxr_javadoccomment">     * used; also see {@link javax.mail.internet.MimeBodyPart} for definitions</em>
+<a class="jxr_linenumber" name="L316" href="#L316">316</a> <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L317" href="#L317">317</a> <em class="jxr_javadoccomment">     * @see #embed(File, String)</em>
+<a class="jxr_linenumber" name="L318" href="#L318">318</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
+<a class="jxr_linenumber" name="L319" href="#L319">319</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L320" href="#L320">320</a>     <strong class="jxr_keyword">public</strong> String embed(<strong class="jxr_keyword">final</strong> File file) <strong class="jxr_keyword">throws</strong> EmailException
+<a class="jxr_linenumber" name="L321" href="#L321">321</a>     {
+<a class="jxr_linenumber" name="L322" href="#L322">322</a>         <strong class="jxr_keyword">final</strong> String cid = EmailUtils.randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase(Locale.ENGLISH);
+<a class="jxr_linenumber" name="L323" href="#L323">323</a>         <strong class="jxr_keyword">return</strong> embed(file, cid);
+<a class="jxr_linenumber" name="L324" href="#L324">324</a>     }
+<a class="jxr_linenumber" name="L325" href="#L325">325</a> 
+<a class="jxr_linenumber" name="L326" href="#L326">326</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L327" href="#L327">327</a> <em class="jxr_javadoccomment">     * Embeds a file in the HTML.</em>
+<a class="jxr_linenumber" name="L328" href="#L328">328</a> <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L329" href="#L329">329</a> <em class="jxr_javadoccomment">     * &lt;p&gt;This method embeds a file located by an URL into</em>
+<a class="jxr_linenumber" name="L330" href="#L330">330</a> <em class="jxr_javadoccomment">     * the mail body. It allows, for instance, to add inline images</em>
+<a class="jxr_linenumber" name="L331" href="#L331">331</a> <em class="jxr_javadoccomment">     * to the email.  Inline files may be referenced with a</em>
+<a class="jxr_linenumber" name="L332" href="#L332">332</a> <em class="jxr_javadoccomment">     * &lt;code&gt;cid:xxxxxx&lt;/code&gt; URL, where xxxxxx is the Content-ID</em>
+<a class="jxr_linenumber" name="L333" href="#L333">333</a> <em class="jxr_javadoccomment">     * returned by the embed function. Files are bound to their names, which is</em>
+<a class="jxr_linenumber" name="L334" href="#L334">334</a> <em class="jxr_javadoccomment">     * the value returned by {@link java.io.File#getName()}. If the same file</em>
+<a class="jxr_linenumber" name="L335" href="#L335">335</a> <em class="jxr_javadoccomment">     * is embedded multiple times, the same CID is guaranteed to be returned.</em>
+<a class="jxr_linenumber" name="L336" href="#L336">336</a> <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L337" href="#L337">337</a> <em class="jxr_javadoccomment">     * &lt;p&gt;While functionally the same as passing &lt;code&gt;FileDataSource&lt;/code&gt; to</em>
+<a class="jxr_linenumber" name="L338" href="#L338">338</a> <em class="jxr_javadoccomment">     * {@link #embed(DataSource, String, String)}, this method attempts</em>
+<a class="jxr_linenumber" name="L339" href="#L339">339</a> <em class="jxr_javadoccomment">     * to validate the file before embedding it in the message and will throw</em>
+<a class="jxr_linenumber" name="L340" href="#L340">340</a> <em class="jxr_javadoccomment">     * &lt;code&gt;EmailException&lt;/code&gt; if the validation fails. In this case, the</em>
+<a class="jxr_linenumber" name="L341" href="#L341">341</a> <em class="jxr_javadoccomment">     * &lt;code&gt;HtmlEmail&lt;/code&gt; object will not be changed.</em>
+<a class="jxr_linenumber" name="L342" href="#L342">342</a> <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L343" href="#L343">343</a> <em class="jxr_javadoccomment">     * @param file The &lt;code&gt;File&lt;/code&gt; to embed</em>
+<a class="jxr_linenumber" name="L344" href="#L344">344</a> <em class="jxr_javadoccomment">     * @param cid the Content-ID to use for the embedded &lt;code&gt;File&lt;/code&gt;</em>
+<a class="jxr_linenumber" name="L345" href="#L345">345</a> <em class="jxr_javadoccomment">     * @return A String with the Content-ID of the file.</em>
+<a class="jxr_linenumber" name="L346" href="#L346">346</a> <em class="jxr_javadoccomment">     * @throws EmailException when the supplied &lt;code&gt;File&lt;/code&gt; cannot be used</em>
+<a class="jxr_linenumber" name="L347" href="#L347">347</a> <em class="jxr_javadoccomment">     *  or if the file has already been embedded;</em>
+<a class="jxr_linenumber" name="L348" href="#L348">348</a> <em class="jxr_javadoccomment">     *  also see {@link javax.mail.internet.MimeBodyPart} for definitions</em>
+<a class="jxr_linenumber" name="L349" href="#L349">349</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
+<a class="jxr_linenumber" name="L350" href="#L350">350</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L351" href="#L351">351</a>     <strong class="jxr_keyword">public</strong> String embed(<strong class="jxr_keyword">final</strong> File file, <strong class="jxr_keyword">final</strong> String cid) <strong class="jxr_keyword">throws</strong> EmailException
+<a class="jxr_linenumber" name="L352" href="#L352">352</a>     {
+<a class="jxr_linenumber" name="L353" href="#L353">353</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isEmpty(file.getName()))
+<a class="jxr_linenumber" name="L354" href="#L354">354</a>         {
+<a class="jxr_linenumber" name="L355" href="#L355">355</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"file name cannot be null or empty"</span>);
+<a class="jxr_linenumber" name="L356" href="#L356">356</a>         }
+<a class="jxr_linenumber" name="L357" href="#L357">357</a> 
+<a class="jxr_linenumber" name="L358" href="#L358">358</a>         <em class="jxr_comment">// verify that the File can provide a canonical path</em>
+<a class="jxr_linenumber" name="L359" href="#L359">359</a>         String filePath = <strong class="jxr_keyword">null</strong>;
+<a class="jxr_linenumber" name="L360" href="#L360">360</a>         <strong class="jxr_keyword">try</strong>
+<a class="jxr_linenumber" name="L361" href="#L361">361</a>         {
+<a class="jxr_linenumber" name="L362" href="#L362">362</a>             filePath = file.getCanonicalPath();
+<a class="jxr_linenumber" name="L363" href="#L363">363</a>         }
+<a class="jxr_linenumber" name="L364" href="#L364">364</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> IOException ioe)
+<a class="jxr_linenumber" name="L365" href="#L365">365</a>         {
+<a class="jxr_linenumber" name="L366" href="#L366">366</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"couldn't get canonical path for "</span>
+<a class="jxr_linenumber" name="L367" href="#L367">367</a>                     + file.getName(), ioe);
+<a class="jxr_linenumber" name="L368" href="#L368">368</a>         }
+<a class="jxr_linenumber" name="L369" href="#L369">369</a> 
+<a class="jxr_linenumber" name="L370" href="#L370">370</a>         <em class="jxr_comment">// check if a FileDataSource for this name has already been attached;</em>
+<a class="jxr_linenumber" name="L371" href="#L371">371</a>         <em class="jxr_comment">// if so, return the cached CID value.</em>
+<a class="jxr_linenumber" name="L372" href="#L372">372</a>         <strong class="jxr_keyword">if</strong> (inlineEmbeds.containsKey(file.getName()))
+<a class="jxr_linenumber" name="L373" href="#L373">373</a>         {
+<a class="jxr_linenumber" name="L374" href="#L374">374</a>             <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a> ii = inlineEmbeds.get(file.getName());
+<a class="jxr_linenumber" name="L375" href="#L375">375</a>             <strong class="jxr_keyword">final</strong> FileDataSource fileDataSource = (FileDataSource) ii.getDataSource();
+<a class="jxr_linenumber" name="L376" href="#L376">376</a>             <em class="jxr_comment">// make sure the supplied file has the same canonical path</em>
+<a class="jxr_linenumber" name="L377" href="#L377">377</a>             <em class="jxr_comment">// as the one already associated with this name.</em>
+<a class="jxr_linenumber" name="L378" href="#L378">378</a>             String existingFilePath = <strong class="jxr_keyword">null</strong>;
+<a class="jxr_linenumber" name="L379" href="#L379">379</a>             <strong class="jxr_keyword">try</strong>
+<a class="jxr_linenumber" name="L380" href="#L380">380</a>             {
+<a class="jxr_linenumber" name="L381" href="#L381">381</a>                 existingFilePath = fileDataSource.getFile().getCanonicalPath();
+<a class="jxr_linenumber" name="L382" href="#L382">382</a>             }
+<a class="jxr_linenumber" name="L383" href="#L383">383</a>             <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> IOException ioe)
+<a class="jxr_linenumber" name="L384" href="#L384">384</a>             {
+<a class="jxr_linenumber" name="L385" href="#L385">385</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"couldn't get canonical path for file "</span>
+<a class="jxr_linenumber" name="L386" href="#L386">386</a>                         + fileDataSource.getFile().getName()
+<a class="jxr_linenumber" name="L387" href="#L387">387</a>                         + <span class="jxr_string">"which has already been embedded"</span>, ioe);
+<a class="jxr_linenumber" name="L388" href="#L388">388</a>             }
+<a class="jxr_linenumber" name="L389" href="#L389">389</a>             <strong class="jxr_keyword">if</strong> (filePath.equals(existingFilePath))
+<a class="jxr_linenumber" name="L390" href="#L390">390</a>             {
+<a class="jxr_linenumber" name="L391" href="#L391">391</a>                 <strong class="jxr_keyword">return</strong> ii.getCid();
+<a class="jxr_linenumber" name="L392" href="#L392">392</a>             }
+<a class="jxr_linenumber" name="L393" href="#L393">393</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"embedded name '"</span> + file.getName()
+<a class="jxr_linenumber" name="L394" href="#L394">394</a>                 + <span class="jxr_string">"' is already bound to file "</span> + existingFilePath
+<a class="jxr_linenumber" name="L395" href="#L395">395</a>                 + <span class="jxr_string">"; existing names cannot be rebound"</span>);
+<a class="jxr_linenumber" name="L396" href="#L396">396</a>         }
+<a class="jxr_linenumber" name="L397" href="#L397">397</a> 
+<a class="jxr_linenumber" name="L398" href="#L398">398</a>         <em class="jxr_comment">// verify that the file is valid</em>
+<a class="jxr_linenumber" name="L399" href="#L399">399</a>         <strong class="jxr_keyword">if</strong> (!file.exists())
+<a class="jxr_linenumber" name="L400" href="#L400">400</a>         {
+<a class="jxr_linenumber" name="L401" href="#L401">401</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"file "</span> + filePath + <span class="jxr_string">" doesn't exist"</span>);
 <a class="jxr_linenumber" name="L402" href="#L402">402</a>         }
-<a class="jxr_linenumber" name="L403" href="#L403">403</a> 
-<a class="jxr_linenumber" name="L404" href="#L404">404</a>         <em class="jxr_comment">// verify that the file is valid</em>
-<a class="jxr_linenumber" name="L405" href="#L405">405</a>         <strong class="jxr_keyword">if</strong> (!file.exists())
-<a class="jxr_linenumber" name="L406" href="#L406">406</a>         {
-<a class="jxr_linenumber" name="L407" href="#L407">407</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"file "</span> + filePath + <span class="jxr_string">" doesn't exist"</span>);
-<a class="jxr_linenumber" name="L408" href="#L408">408</a>         }
-<a class="jxr_linenumber" name="L409" href="#L409">409</a>         <strong class="jxr_keyword">if</strong> (!file.isFile())
-<a class="jxr_linenumber" name="L410" href="#L410">410</a>         {
-<a class="jxr_linenumber" name="L411" href="#L411">411</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"file "</span> + filePath + <span class="jxr_string">" isn't a normal file"</span>);
-<a class="jxr_linenumber" name="L412" href="#L412">412</a>         }
-<a class="jxr_linenumber" name="L413" href="#L413">413</a>         <strong class="jxr_keyword">if</strong> (!file.canRead())
-<a class="jxr_linenumber" name="L414" href="#L414">414</a>         {
-<a class="jxr_linenumber" name="L415" href="#L415">415</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"file "</span> + filePath + <span class="jxr_string">" isn't readable"</span>);
-<a class="jxr_linenumber" name="L416" href="#L416">416</a>         }
-<a class="jxr_linenumber" name="L417" href="#L417">417</a> 
-<a class="jxr_linenumber" name="L418" href="#L418">418</a>         <strong class="jxr_keyword">return</strong> embed(<strong class="jxr_keyword">new</strong> FileDataSource(file), file.getName(), cid);
-<a class="jxr_linenumber" name="L419" href="#L419">419</a>     }
-<a class="jxr_linenumber" name="L420" href="#L420">420</a> 
-<a class="jxr_linenumber" name="L421" href="#L421">421</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L422" href="#L422">422</a> <em class="jxr_javadoccomment">     * Embeds the specified &lt;code&gt;DataSource&lt;/code&gt; in the HTML using a</em>
-<a class="jxr_linenumber" name="L423" href="#L423">423</a> <em class="jxr_javadoccomment">     * randomly generated Content-ID. Returns the generated Content-ID string.</em>
-<a class="jxr_linenumber" name="L424" href="#L424">424</a> <em class="jxr_javadoccomment">     *</em>
-<a class="jxr_linenumber" name="L425" href="#L425">425</a> <em class="jxr_javadoccomment">     * @param dataSource the &lt;code&gt;DataSource&lt;/code&gt; to embed</em>
-<a class="jxr_linenumber" name="L426" href="#L426">426</a> <em class="jxr_javadoccomment">     * @param name the name that will be set in the filename header field</em>
-<a class="jxr_linenumber" name="L427" href="#L427">427</a> <em class="jxr_javadoccomment">     * @return the generated Content-ID for this &lt;code&gt;DataSource&lt;/code&gt;</em>
-<a class="jxr_linenumber" name="L428" href="#L428">428</a> <em class="jxr_javadoccomment">     * @throws EmailException if the embedding fails or if &lt;code&gt;name&lt;/code&gt; is</em>
-<a class="jxr_linenumber" name="L429" href="#L429">429</a> <em class="jxr_javadoccomment">     * null or empty</em>
-<a class="jxr_linenumber" name="L430" href="#L430">430</a> <em class="jxr_javadoccomment">     * @see #embed(DataSource, String, String)</em>
-<a class="jxr_linenumber" name="L431" href="#L431">431</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
-<a class="jxr_linenumber" name="L432" href="#L432">432</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L433" href="#L433">433</a>     <strong class="jxr_keyword">public</strong> String embed(<strong class="jxr_keyword">final</strong> DataSource dataSource, <strong class="jxr_keyword">final</strong> String name) <strong class="jxr_keyword">throws</strong> EmailException
-<a class="jxr_linenumber" name="L434" href="#L434">434</a>     {
-<a class="jxr_linenumber" name="L435" href="#L435">435</a>         <em class="jxr_comment">// check if the DataSource has already been attached;</em>
-<a class="jxr_linenumber" name="L436" href="#L436">436</a>         <em class="jxr_comment">// if so, return the cached CID value.</em>
-<a class="jxr_linenumber" name="L437" href="#L437">437</a>         <strong class="jxr_keyword">if</strong> (inlineEmbeds.containsKey(name))
-<a class="jxr_linenumber" name="L438" href="#L438">438</a>         {
-<a class="jxr_linenumber" name="L439" href="#L439">439</a>             <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a> ii = inlineEmbeds.get(name);
-<a class="jxr_linenumber" name="L440" href="#L440">440</a>             <em class="jxr_comment">// make sure the supplied URL points to the same thing</em>
-<a class="jxr_linenumber" name="L441" href="#L441">441</a>             <em class="jxr_comment">// as the one already associated with this name.</em>
-<a class="jxr_linenumber" name="L442" href="#L442">442</a>             <strong class="jxr_keyword">if</strong> (dataSource.equals(ii.getDataSource()))
-<a class="jxr_linenumber" name="L443" href="#L443">443</a>             {
-<a class="jxr_linenumber" name="L444" href="#L444">444</a>                 <strong class="jxr_keyword">return</strong> ii.getCid();
-<a class="jxr_linenumber" name="L445" href="#L445">445</a>             }
-<a class="jxr_linenumber" name="L446" href="#L446">446</a>             <strong class="jxr_keyword">else</strong>
-<a class="jxr_linenumber" name="L447" href="#L447">447</a>             {
-<a class="jxr_linenumber" name="L448" href="#L448">448</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"embedded DataSource '"</span> + name
-<a class="jxr_linenumber" name="L449" href="#L449">449</a>                     + <span class="jxr_string">"' is already bound to name "</span> + ii.getDataSource().toString()
-<a class="jxr_linenumber" name="L450" href="#L450">450</a>                     + <span class="jxr_string">"; existing names cannot be rebound"</span>);
-<a class="jxr_linenumber" name="L451" href="#L451">451</a>             }
-<a class="jxr_linenumber" name="L452" href="#L452">452</a>         }
-<a class="jxr_linenumber" name="L453" href="#L453">453</a> 
-<a class="jxr_linenumber" name="L454" href="#L454">454</a>         <strong class="jxr_keyword">final</strong> String cid = EmailUtils.randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase();
-<a class="jxr_linenumber" name="L455" href="#L455">455</a>         <strong class="jxr_keyword">return</strong> embed(dataSource, name, cid);
-<a class="jxr_linenumber" name="L456" href="#L456">456</a>     }
-<a class="jxr_linenumber" name="L457" href="#L457">457</a> 
-<a class="jxr_linenumber" name="L458" href="#L458">458</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L459" href="#L459">459</a> <em class="jxr_javadoccomment">     * Embeds the specified &lt;code&gt;DataSource&lt;/code&gt; in the HTML using the</em>
-<a class="jxr_linenumber" name="L460" href="#L460">460</a> <em class="jxr_javadoccomment">     * specified Content-ID. Returns the specified Content-ID string.</em>
-<a class="jxr_linenumber" name="L461" href="#L461">461</a> <em class="jxr_javadoccomment">     *</em>
-<a class="jxr_linenumber" name="L462" href="#L462">462</a> <em class="jxr_javadoccomment">     * @param dataSource the &lt;code&gt;DataSource&lt;/code&gt; to embed</em>
-<a class="jxr_linenumber" name="L463" href="#L463">463</a> <em class="jxr_javadoccomment">     * @param name the name that will be set in the filename header field</em>
-<a class="jxr_linenumber" name="L464" href="#L464">464</a> <em class="jxr_javadoccomment">     * @param cid the Content-ID to use for this &lt;code&gt;DataSource&lt;/code&gt;</em>
-<a class="jxr_linenumber" name="L465" href="#L465">465</a> <em class="jxr_javadoccomment">     * @return the URL encoded Content-ID for this &lt;code&gt;DataSource&lt;/code&gt;</em>
-<a class="jxr_linenumber" name="L466" href="#L466">466</a> <em class="jxr_javadoccomment">     * @throws EmailException if the embedding fails or if &lt;code&gt;name&lt;/code&gt; is</em>
-<a class="jxr_linenumber" name="L467" href="#L467">467</a> <em class="jxr_javadoccomment">     * null or empty</em>
-<a class="jxr_linenumber" name="L468" href="#L468">468</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
-<a class="jxr_linenumber" name="L469" href="#L469">469</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L470" href="#L470">470</a>     <strong class="jxr_keyword">public</strong> String embed(<strong class="jxr_keyword">final</strong> DataSource dataSource, <strong class="jxr_keyword">final</strong> String name, String cid)
-<a class="jxr_linenumber" name="L471" href="#L471">471</a>         <strong class="jxr_keyword">throws</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>
-<a class="jxr_linenumber" name="L472" href="#L472">472</a>     {
-<a class="jxr_linenumber" name="L473" href="#L473">473</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isEmpty(name))
-<a class="jxr_linenumber" name="L474" href="#L474">474</a>         {
-<a class="jxr_linenumber" name="L475" href="#L475">475</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"name cannot be null or empty"</span>);
-<a class="jxr_linenumber" name="L476" href="#L476">476</a>         }
-<a class="jxr_linenumber" name="L477" href="#L477">477</a> 
-<a class="jxr_linenumber" name="L478" href="#L478">478</a>         <strong class="jxr_keyword">final</strong> MimeBodyPart mbp = <strong class="jxr_keyword">new</strong> MimeBodyPart();
-<a class="jxr_linenumber" name="L479" href="#L479">479</a> 
-<a class="jxr_linenumber" name="L480" href="#L480">480</a>         <strong class="jxr_keyword">try</strong>
-<a class="jxr_linenumber" name="L481" href="#L481">481</a>         {
-<a class="jxr_linenumber" name="L482" href="#L482">482</a>             <em class="jxr_comment">// url encode the cid according to rfc 2392</em>
-<a class="jxr_linenumber" name="L483" href="#L483">483</a>             cid = EmailUtils.encodeUrl(cid);
-<a class="jxr_linenumber" name="L484" href="#L484">484</a> 
-<a class="jxr_linenumber" name="L485" href="#L485">485</a>             mbp.setDataHandler(<strong class="jxr_keyword">new</strong> DataHandler(dataSource));
-<a class="jxr_linenumber" name="L486" href="#L486">486</a>             mbp.setFileName(name);
-<a class="jxr_linenumber" name="L487" href="#L487">487</a>             mbp.setDisposition(EmailAttachment.INLINE);
-<a class="jxr_linenumber" name="L488" href="#L488">488</a>             mbp.setContentID(<span class="jxr_string">"&lt;"</span> + cid + <span class="jxr_string">"&gt;"</span>);
-<a class="jxr_linenumber" name="L489" href="#L489">489</a> 
-<a class="jxr_linenumber" name="L490" href="#L490">490</a>             <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a> ii = <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a>(cid, dataSource, mbp);
-<a class="jxr_linenumber" name="L491" href="#L491">491</a>             <strong class="jxr_keyword">this</strong>.inlineEmbeds.put(name, ii);
-<a class="jxr_linenumber" name="L492" href="#L492">492</a> 
-<a class="jxr_linenumber" name="L493" href="#L493">493</a>             <strong class="jxr_keyword">return</strong> cid;
-<a class="jxr_linenumber" name="L494" href="#L494">494</a>         }
-<a class="jxr_linenumber" name="L495" href="#L495">495</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> MessagingException me)
-<a class="jxr_linenumber" name="L496" href="#L496">496</a>         {
-<a class="jxr_linenumber" name="L497" href="#L497">497</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(me);
-<a class="jxr_linenumber" name="L498" href="#L498">498</a>         }
-<a class="jxr_linenumber" name="L499" href="#L499">499</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> UnsupportedEncodingException uee)
-<a class="jxr_linenumber" name="L500" href="#L500">500</a>         {
-<a class="jxr_linenumber" name="L501" href="#L501">501</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(uee);
-<a class="jxr_linenumber" name="L502" href="#L502">502</a>         }
-<a class="jxr_linenumber" name="L503" href="#L503">503</a>     }
-<a class="jxr_linenumber" name="L504" href="#L504">504</a> 
-<a class="jxr_linenumber" name="L505" href="#L505">505</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L506" href="#L506">506</a> <em class="jxr_javadoccomment">     * Does the work of actually building the MimeMessage. Please note that</em>
-<a class="jxr_linenumber" name="L507" href="#L507">507</a> <em class="jxr_javadoccomment">     * a user rarely calls this method directly and only if he/she is</em>
-<a class="jxr_linenumber" name="L508" href="#L508">508</a> <em class="jxr_javadoccomment">     * interested in the sending the underlying MimeMessage without</em>
-<a class="jxr_linenumber" name="L509" href="#L509">509</a> <em class="jxr_javadoccomment">     * commons-email.</em>
-<a class="jxr_linenumber" name="L510" href="#L510">510</a> <em class="jxr_javadoccomment">     *</em>
-<a class="jxr_linenumber" name="L511" href="#L511">511</a> <em class="jxr_javadoccomment">     * @exception EmailException if there was an error.</em>
-<a class="jxr_linenumber" name="L512" href="#L512">512</a> <em class="jxr_javadoccomment">     * @since 1.0</em>
-<a class="jxr_linenumber" name="L513" href="#L513">513</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L514" href="#L514">514</a>     @Override
-<a class="jxr_linenumber" name="L515" href="#L515">515</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> buildMimeMessage() <strong class="jxr_keyword">throws</strong> EmailException
-<a class="jxr_linenumber" name="L516" href="#L516">516</a>     {
-<a class="jxr_linenumber" name="L517" href="#L517">517</a>         <strong class="jxr_keyword">try</strong>
-<a class="jxr_linenumber" name="L518" href="#L518">518</a>         {
-<a class="jxr_linenumber" name="L519" href="#L519">519</a>             build();
-<a class="jxr_linenumber" name="L520" href="#L520">520</a>         }
-<a class="jxr_linenumber" name="L521" href="#L521">521</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> MessagingException me)
-<a class="jxr_linenumber" name="L522" href="#L522">522</a>         {
-<a class="jxr_linenumber" name="L523" href="#L523">523</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(me);
-<a class="jxr_linenumber" name="L524" href="#L524">524</a>         }
-<a class="jxr_linenumber" name="L525" href="#L525">525</a>         <strong class="jxr_keyword">super</strong>.buildMimeMessage();
-<a class="jxr_linenumber" name="L526" href="#L526">526</a>     }
-<a class="jxr_linenumber" name="L527" href="#L527">527</a> 
-<a class="jxr_linenumber" name="L528" href="#L528">528</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L529" href="#L529">529</a> <em class="jxr_javadoccomment">     * @throws EmailException EmailException</em>
-<a class="jxr_linenumber" name="L530" href="#L530">530</a> <em class="jxr_javadoccomment">     * @throws MessagingException MessagingException</em>
-<a class="jxr_linenumber" name="L531" href="#L531">531</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L532" href="#L532">532</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> build() <strong class="jxr_keyword">throws</strong> MessagingException, EmailException
-<a class="jxr_linenumber" name="L533" href="#L533">533</a>     {
-<a class="jxr_linenumber" name="L534" href="#L534">534</a>         <strong class="jxr_keyword">final</strong> MimeMultipart rootContainer = <strong class="jxr_keyword">this</strong>.getContainer();
-<a class="jxr_linenumber" name="L535" href="#L535">535</a>         MimeMultipart bodyEmbedsContainer = rootContainer;
-<a class="jxr_linenumber" name="L536" href="#L536">536</a>         MimeMultipart bodyContainer = rootContainer;
-<a class="jxr_linenumber" name="L537" href="#L537">537</a>         MimeBodyPart msgHtml = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="L538" href="#L538">538</a>         MimeBodyPart msgText = <strong class="jxr_keyword">null</strong>;
-<a class="jxr_linenumber" name="L539" href="#L539">539</a> 
-<a class="jxr_linenumber" name="L540" href="#L540">540</a>         rootContainer.setSubType(<span class="jxr_string">"mixed"</span>);
+<a class="jxr_linenumber" name="L403" href="#L403">403</a>         <strong class="jxr_keyword">if</strong> (!file.isFile())
+<a class="jxr_linenumber" name="L404" href="#L404">404</a>         {
+<a class="jxr_linenumber" name="L405" href="#L405">405</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"file "</span> + filePath + <span class="jxr_string">" isn't a normal file"</span>);
+<a class="jxr_linenumber" name="L406" href="#L406">406</a>         }
+<a class="jxr_linenumber" name="L407" href="#L407">407</a>         <strong class="jxr_keyword">if</strong> (!file.canRead())
+<a class="jxr_linenumber" name="L408" href="#L408">408</a>         {
+<a class="jxr_linenumber" name="L409" href="#L409">409</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"file "</span> + filePath + <span class="jxr_string">" isn't readable"</span>);
+<a class="jxr_linenumber" name="L410" href="#L410">410</a>         }
+<a class="jxr_linenumber" name="L411" href="#L411">411</a> 
+<a class="jxr_linenumber" name="L412" href="#L412">412</a>         <strong class="jxr_keyword">return</strong> embed(<strong class="jxr_keyword">new</strong> FileDataSource(file), file.getName(), cid);
+<a class="jxr_linenumber" name="L413" href="#L413">413</a>     }
+<a class="jxr_linenumber" name="L414" href="#L414">414</a> 
+<a class="jxr_linenumber" name="L415" href="#L415">415</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L416" href="#L416">416</a> <em class="jxr_javadoccomment">     * Embeds the specified &lt;code&gt;DataSource&lt;/code&gt; in the HTML using a</em>
+<a class="jxr_linenumber" name="L417" href="#L417">417</a> <em class="jxr_javadoccomment">     * randomly generated Content-ID. Returns the generated Content-ID string.</em>
+<a class="jxr_linenumber" name="L418" href="#L418">418</a> <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L419" href="#L419">419</a> <em class="jxr_javadoccomment">     * @param dataSource the &lt;code&gt;DataSource&lt;/code&gt; to embed</em>
+<a class="jxr_linenumber" name="L420" href="#L420">420</a> <em class="jxr_javadoccomment">     * @param name the name that will be set in the filename header field</em>
+<a class="jxr_linenumber" name="L421" href="#L421">421</a> <em class="jxr_javadoccomment">     * @return the generated Content-ID for this &lt;code&gt;DataSource&lt;/code&gt;</em>
+<a class="jxr_linenumber" name="L422" href="#L422">422</a> <em class="jxr_javadoccomment">     * @throws EmailException if the embedding fails or if &lt;code&gt;name&lt;/code&gt; is</em>
+<a class="jxr_linenumber" name="L423" href="#L423">423</a> <em class="jxr_javadoccomment">     * null or empty</em>
+<a class="jxr_linenumber" name="L424" href="#L424">424</a> <em class="jxr_javadoccomment">     * @see #embed(DataSource, String, String)</em>
+<a class="jxr_linenumber" name="L425" href="#L425">425</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
+<a class="jxr_linenumber" name="L426" href="#L426">426</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L427" href="#L427">427</a>     <strong class="jxr_keyword">public</strong> String embed(<strong class="jxr_keyword">final</strong> DataSource dataSource, <strong class="jxr_keyword">final</strong> String name) <strong class="jxr_keyword">throws</strong> EmailException
+<a class="jxr_linenumber" name="L428" href="#L428">428</a>     {
+<a class="jxr_linenumber" name="L429" href="#L429">429</a>         <em class="jxr_comment">// check if the DataSource has already been attached;</em>
+<a class="jxr_linenumber" name="L430" href="#L430">430</a>         <em class="jxr_comment">// if so, return the cached CID value.</em>
+<a class="jxr_linenumber" name="L431" href="#L431">431</a>         <strong class="jxr_keyword">if</strong> (inlineEmbeds.containsKey(name))
+<a class="jxr_linenumber" name="L432" href="#L432">432</a>         {
+<a class="jxr_linenumber" name="L433" href="#L433">433</a>             <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a> ii = inlineEmbeds.get(name);
+<a class="jxr_linenumber" name="L434" href="#L434">434</a>             <em class="jxr_comment">// make sure the supplied URL points to the same thing</em>
+<a class="jxr_linenumber" name="L435" href="#L435">435</a>             <em class="jxr_comment">// as the one already associated with this name.</em>
+<a class="jxr_linenumber" name="L436" href="#L436">436</a>             <strong class="jxr_keyword">if</strong> (dataSource.equals(ii.getDataSource()))
+<a class="jxr_linenumber" name="L437" href="#L437">437</a>             {
+<a class="jxr_linenumber" name="L438" href="#L438">438</a>                 <strong class="jxr_keyword">return</strong> ii.getCid();
+<a class="jxr_linenumber" name="L439" href="#L439">439</a>             }
+<a class="jxr_linenumber" name="L440" href="#L440">440</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"embedded DataSource '"</span> + name
+<a class="jxr_linenumber" name="L441" href="#L441">441</a>                 + <span class="jxr_string">"' is already bound to name "</span> + ii.getDataSource().toString()
+<a class="jxr_linenumber" name="L442" href="#L442">442</a>                 + <span class="jxr_string">"; existing names cannot be rebound"</span>);
+<a class="jxr_linenumber" name="L443" href="#L443">443</a>         }
+<a class="jxr_linenumber" name="L444" href="#L444">444</a> 
+<a class="jxr_linenumber" name="L445" href="#L445">445</a>         <strong class="jxr_keyword">final</strong> String cid = EmailUtils.randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase();
+<a class="jxr_linenumber" name="L446" href="#L446">446</a>         <strong class="jxr_keyword">return</strong> embed(dataSource, name, cid);
+<a class="jxr_linenumber" name="L447" href="#L447">447</a>     }
+<a class="jxr_linenumber" name="L448" href="#L448">448</a> 
+<a class="jxr_linenumber" name="L449" href="#L449">449</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L450" href="#L450">450</a> <em class="jxr_javadoccomment">     * Embeds the specified &lt;code&gt;DataSource&lt;/code&gt; in the HTML using the</em>
+<a class="jxr_linenumber" name="L451" href="#L451">451</a> <em class="jxr_javadoccomment">     * specified Content-ID. Returns the specified Content-ID string.</em>
+<a class="jxr_linenumber" name="L452" href="#L452">452</a> <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L453" href="#L453">453</a> <em class="jxr_javadoccomment">     * @param dataSource the &lt;code&gt;DataSource&lt;/code&gt; to embed</em>
+<a class="jxr_linenumber" name="L454" href="#L454">454</a> <em class="jxr_javadoccomment">     * @param name the name that will be set in the filename header field</em>
+<a class="jxr_linenumber" name="L455" href="#L455">455</a> <em class="jxr_javadoccomment">     * @param cid the Content-ID to use for this &lt;code&gt;DataSource&lt;/code&gt;</em>
+<a class="jxr_linenumber" name="L456" href="#L456">456</a> <em class="jxr_javadoccomment">     * @return the URL encoded Content-ID for this &lt;code&gt;DataSource&lt;/code&gt;</em>
+<a class="jxr_linenumber" name="L457" href="#L457">457</a> <em class="jxr_javadoccomment">     * @throws EmailException if the embedding fails or if &lt;code&gt;name&lt;/code&gt; is</em>
+<a class="jxr_linenumber" name="L458" href="#L458">458</a> <em class="jxr_javadoccomment">     * null or empty</em>
+<a class="jxr_linenumber" name="L459" href="#L459">459</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
+<a class="jxr_linenumber" name="L460" href="#L460">460</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L461" href="#L461">461</a>     <strong class="jxr_keyword">public</strong> String embed(<strong class="jxr_keyword">final</strong> DataSource dataSource, <strong class="jxr_keyword">final</strong> String name, <strong class="jxr_keyword">final</strong> String cid)
+<a class="jxr_linenumber" name="L462" href="#L462">462</a>         <strong class="jxr_keyword">throws</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>
+<a class="jxr_linenumber" name="L463" href="#L463">463</a>     {
+<a class="jxr_linenumber" name="L464" href="#L464">464</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isEmpty(name))
+<a class="jxr_linenumber" name="L465" href="#L465">465</a>         {
+<a class="jxr_linenumber" name="L466" href="#L466">466</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(<span class="jxr_string">"name cannot be null or empty"</span>);
+<a class="jxr_linenumber" name="L467" href="#L467">467</a>         }
+<a class="jxr_linenumber" name="L468" href="#L468">468</a> 
+<a class="jxr_linenumber" name="L469" href="#L469">469</a>         <strong class="jxr_keyword">final</strong> MimeBodyPart mbp = <strong class="jxr_keyword">new</strong> MimeBodyPart();
+<a class="jxr_linenumber" name="L470" href="#L470">470</a> 
+<a class="jxr_linenumber" name="L471" href="#L471">471</a>         <strong class="jxr_keyword">try</strong>
+<a class="jxr_linenumber" name="L472" href="#L472">472</a>         {
+<a class="jxr_linenumber" name="L473" href="#L473">473</a>             <em class="jxr_comment">// URL encode the cid according to RFC 2392</em>
+<a class="jxr_linenumber" name="L474" href="#L474">474</a>             String encodedCid = EmailUtils.encodeUrl(cid);
+<a class="jxr_linenumber" name="L475" href="#L475">475</a> 
+<a class="jxr_linenumber" name="L476" href="#L476">476</a>             mbp.setDataHandler(<strong class="jxr_keyword">new</strong> DataHandler(dataSource));
+<a class="jxr_linenumber" name="L477" href="#L477">477</a>             mbp.setFileName(name);
+<a class="jxr_linenumber" name="L478" href="#L478">478</a>             mbp.setDisposition(EmailAttachment.INLINE);
+<a class="jxr_linenumber" name="L479" href="#L479">479</a>             mbp.setContentID(<span class="jxr_string">"&lt;"</span> + encodedCid + <span class="jxr_string">"&gt;"</span>);
+<a class="jxr_linenumber" name="L480" href="#L480">480</a> 
+<a class="jxr_linenumber" name="L481" href="#L481">481</a>             <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a> ii = <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a>(encodedCid, dataSource, mbp);
+<a class="jxr_linenumber" name="L482" href="#L482">482</a>             <strong class="jxr_keyword">this</strong>.inlineEmbeds.put(name, ii);
+<a class="jxr_linenumber" name="L483" href="#L483">483</a> 
+<a class="jxr_linenumber" name="L484" href="#L484">484</a>             <strong class="jxr_keyword">return</strong> encodedCid;
+<a class="jxr_linenumber" name="L485" href="#L485">485</a>         }
+<a class="jxr_linenumber" name="L486" href="#L486">486</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> MessagingException me)
+<a class="jxr_linenumber" name="L487" href="#L487">487</a>         {
+<a class="jxr_linenumber" name="L488" href="#L488">488</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(me);
+<a class="jxr_linenumber" name="L489" href="#L489">489</a>         }
+<a class="jxr_linenumber" name="L490" href="#L490">490</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> UnsupportedEncodingException uee)
+<a class="jxr_linenumber" name="L491" href="#L491">491</a>         {
+<a class="jxr_linenumber" name="L492" href="#L492">492</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(uee);
+<a class="jxr_linenumber" name="L493" href="#L493">493</a>         }
+<a class="jxr_linenumber" name="L494" href="#L494">494</a>     }
+<a class="jxr_linenumber" name="L495" href="#L495">495</a> 
+<a class="jxr_linenumber" name="L496" href="#L496">496</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L497" href="#L497">497</a> <em class="jxr_javadoccomment">     * Does the work of actually building the MimeMessage. Please note that</em>
+<a class="jxr_linenumber" name="L498" href="#L498">498</a> <em class="jxr_javadoccomment">     * a user rarely calls this method directly and only if he/she is</em>
+<a class="jxr_linenumber" name="L499" href="#L499">499</a> <em class="jxr_javadoccomment">     * interested in the sending the underlying MimeMessage without</em>
+<a class="jxr_linenumber" name="L500" href="#L500">500</a> <em class="jxr_javadoccomment">     * commons-email.</em>
+<a class="jxr_linenumber" name="L501" href="#L501">501</a> <em class="jxr_javadoccomment">     *</em>
+<a class="jxr_linenumber" name="L502" href="#L502">502</a> <em class="jxr_javadoccomment">     * @exception EmailException if there was an error.</em>
+<a class="jxr_linenumber" name="L503" href="#L503">503</a> <em class="jxr_javadoccomment">     * @since 1.0</em>
+<a class="jxr_linenumber" name="L504" href="#L504">504</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L505" href="#L505">505</a>     @Override
+<a class="jxr_linenumber" name="L506" href="#L506">506</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> buildMimeMessage() <strong class="jxr_keyword">throws</strong> EmailException
+<a class="jxr_linenumber" name="L507" href="#L507">507</a>     {
+<a class="jxr_linenumber" name="L508" href="#L508">508</a>         <strong class="jxr_keyword">try</strong>
+<a class="jxr_linenumber" name="L509" href="#L509">509</a>         {
+<a class="jxr_linenumber" name="L510" href="#L510">510</a>             build();
+<a class="jxr_linenumber" name="L511" href="#L511">511</a>         }
+<a class="jxr_linenumber" name="L512" href="#L512">512</a>         <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> MessagingException me)
+<a class="jxr_linenumber" name="L513" href="#L513">513</a>         {
+<a class="jxr_linenumber" name="L514" href="#L514">514</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(me);
+<a class="jxr_linenumber" name="L515" href="#L515">515</a>         }
+<a class="jxr_linenumber" name="L516" href="#L516">516</a>         <strong class="jxr_keyword">super</strong>.buildMimeMessage();
+<a class="jxr_linenumber" name="L517" href="#L517">517</a>     }
+<a class="jxr_linenumber" name="L518" href="#L518">518</a> 
+<a class="jxr_linenumber" name="L519" href="#L519">519</a>     <em class="jxr_javadoccomment">/**</em>
+<a class="jxr_linenumber" name="L520" href="#L520">520</a> <em class="jxr_javadoccomment">     * @throws EmailException EmailException</em>
+<a class="jxr_linenumber" name="L521" href="#L521">521</a> <em class="jxr_javadoccomment">     * @throws MessagingException MessagingException</em>
+<a class="jxr_linenumber" name="L522" href="#L522">522</a> <em class="jxr_javadoccomment">     */</em>
+<a class="jxr_linenumber" name="L523" href="#L523">523</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> build() <strong class="jxr_keyword">throws</strong> MessagingException, EmailException
+<a class="jxr_linenumber" name="L524" href="#L524">524</a>     {
+<a class="jxr_linenumber" name="L525" href="#L525">525</a>         <strong class="jxr_keyword">final</strong> MimeMultipart rootContainer = <strong class="jxr_keyword">this</strong>.getContainer();
+<a class="jxr_linenumber" name="L526" href="#L526">526</a>         MimeMultipart bodyEmbedsContainer = rootContainer;
+<a class="jxr_linenumber" name="L527" href="#L527">527</a>         MimeMultipart bodyContainer = rootContainer;
+<a class="jxr_linenumber" name="L528" href="#L528">528</a>         MimeBodyPart msgHtml = <strong class="jxr_keyword">null</strong>;
+<a class="jxr_linenumber" name="L529" href="#L529">529</a>         MimeBodyPart msgText = <strong class="jxr_keyword">null</strong>;
+<a class="jxr_linenumber" name="L530" href="#L530">530</a> 
+<a class="jxr_linenumber" name="L531" href="#L531">531</a>         rootContainer.setSubType(<span class="jxr_string">"mixed"</span>);
+<a class="jxr_linenumber" name="L532" href="#L532">532</a> 
+<a class="jxr_linenumber" name="L533" href="#L533">533</a>         <em class="jxr_comment">// determine how to form multiparts of email</em>
+<a class="jxr_linenumber" name="L534" href="#L534">534</a> 
+<a class="jxr_linenumber" name="L535" href="#L535">535</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.html) &amp;&amp; <strong class="jxr_keyword">this</strong>.inlineEmbeds.size() &gt; 0)
+<a class="jxr_linenumber" name="L536" href="#L536">536</a>         {
+<a class="jxr_linenumber" name="L537" href="#L537">537</a>             <em class="jxr_comment">//If HTML body and embeds are used, create a related container and add it to the root container</em>
+<a class="jxr_linenumber" name="L538" href="#L538">538</a>             bodyEmbedsContainer = <strong class="jxr_keyword">new</strong> MimeMultipart(<span class="jxr_string">"related"</span>);
+<a class="jxr_linenumber" name="L539" href="#L539">539</a>             bodyContainer = bodyEmbedsContainer;
+<a class="jxr_linenumber" name="L540" href="#L540">540</a>             <strong class="jxr_keyword">this</strong>.addPart(bodyEmbedsContainer, 0);
 <a class="jxr_linenumber" name="L541" href="#L541">541</a> 
-<a class="jxr_linenumber" name="L542" href="#L542">542</a>         <em class="jxr_comment">// determine how to form multiparts of email</em>
-<a class="jxr_linenumber" name="L543" href="#L543">543</a> 
-<a class="jxr_linenumber" name="L544" href="#L544">544</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.html) &amp;&amp; <strong class="jxr_keyword">this</strong>.inlineEmbeds.size() &gt; 0)
-<a class="jxr_linenumber" name="L545" href="#L545">545</a>         {
-<a class="jxr_linenumber" name="L546" href="#L546">546</a>             <em class="jxr_comment">//If HTML body and embeds are used, create a related container and add it to the root container</em>
-<a class="jxr_linenumber" name="L547" href="#L547">547</a>             bodyEmbedsContainer = <strong class="jxr_keyword">new</strong> MimeMultipart(<span class="jxr_string">"related"</span>);
-<a class="jxr_linenumber" name="L548" href="#L548">548</a>             bodyContainer = bodyEmbedsContainer;
-<a class="jxr_linenumber" name="L549" href="#L549">549</a>             <strong class="jxr_keyword">this</strong>.addPart(bodyEmbedsContainer, 0);
-<a class="jxr_linenumber" name="L550" href="#L550">550</a> 
-<a class="jxr_linenumber" name="L551" href="#L551">551</a>             <em class="jxr_comment">//If TEXT body was specified, create a alternative container and add it to the embeds container</em>
-<a class="jxr_linenumber" name="L552" href="#L552">552</a>             <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.text))
-<a class="jxr_linenumber" name="L553" href="#L553">553</a>             {
-<a class="jxr_linenumber" name="L554" href="#L554">554</a>                 bodyContainer = <strong class="jxr_keyword">new</strong> MimeMultipart(<span class="jxr_string">"alternative"</span>);
-<a class="jxr_linenumber" name="L555" href="#L555">555</a>                 <strong class="jxr_keyword">final</strong> BodyPart bodyPart = createBodyPart();
-<a class="jxr_linenumber" name="L556" href="#L556">556</a>                 <strong class="jxr_keyword">try</strong>
-<a class="jxr_linenumber" name="L557" href="#L557">557</a>                 {
-<a class="jxr_linenumber" name="L558" href="#L558">558</a>                     bodyPart.setContent(bodyContainer);
-<a class="jxr_linenumber" name="L559" href="#L559">559</a>                     bodyEmbedsContainer.addBodyPart(bodyPart, 0);
-<a class="jxr_linenumber" name="L560" href="#L560">560</a>                 }
-<a class="jxr_linenumber" name="L561" href="#L561">561</a>                 <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> MessagingException me)
-<a class="jxr_linenumber" name="L562" href="#L562">562</a>                 {
-<a class="jxr_linenumber" name="L563" href="#L563">563</a>                     <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(me);
-<a class="jxr_linenumber" name="L564" href="#L564">564</a>                 }
-<a class="jxr_linenumber" name="L565" href="#L565">565</a>             }
-<a class="jxr_linenumber" name="L566" href="#L566">566</a>         }
-<a class="jxr_linenumber" name="L567" href="#L567">567</a>         <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.text) &amp;&amp; EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.html))
-<a class="jxr_linenumber" name="L568" href="#L568">568</a>         {
-<a class="jxr_linenumber" name="L569" href="#L569">569</a>             <em class="jxr_comment">//If both HTML and TEXT bodies are provided, create a alternative container and add it to the root container</em>
-<a class="jxr_linenumber" name="L570" href="#L570">570</a>             bodyContainer = <strong class="jxr_keyword">new</strong> MimeMultipart(<span class="jxr_string">"alternative"</span>);
-<a class="jxr_linenumber" name="L571" href="#L571">571</a>             <strong class="jxr_keyword">this</strong>.addPart(bodyContainer, 0);
-<a class="jxr_linenumber" name="L572" href="#L572">572</a>         }
-<a class="jxr_linenumber" name="L573" href="#L573">573</a> 
-<a class="jxr_linenumber" name="L574" href="#L574">574</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.html))
-<a class="jxr_linenumber" name="L575" href="#L575">575</a>         {
-<a class="jxr_linenumber" name="L576" href="#L576">576</a>             msgHtml = <strong class="jxr_keyword">new</strong> MimeBodyPart();
-<a class="jxr_linenumber" name="L577" href="#L577">577</a>             bodyContainer.addBodyPart(msgHtml, 0);
+<a class="jxr_linenumber" name="L542" href="#L542">542</a>             <em class="jxr_comment">// If TEXT body was specified, create a alternative container and add it to the embeds container</em>
+<a class="jxr_linenumber" name="L543" href="#L543">543</a>             <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.text))
+<a class="jxr_linenumber" name="L544" href="#L544">544</a>             {
+<a class="jxr_linenumber" name="L545" href="#L545">545</a>                 bodyContainer = <strong class="jxr_keyword">new</strong> MimeMultipart(<span class="jxr_string">"alternative"</span>);
+<a class="jxr_linenumber" name="L546" href="#L546">546</a>                 <strong class="jxr_keyword">final</strong> BodyPart bodyPart = createBodyPart();
+<a class="jxr_linenumber" name="L547" href="#L547">547</a>                 <strong class="jxr_keyword">try</strong>
+<a class="jxr_linenumber" name="L548" href="#L548">548</a>                 {
+<a class="jxr_linenumber" name="L549" href="#L549">549</a>                     bodyPart.setContent(bodyContainer);
+<a class="jxr_linenumber" name="L550" href="#L550">550</a>                     bodyEmbedsContainer.addBodyPart(bodyPart, 0);
+<a class="jxr_linenumber" name="L551" href="#L551">551</a>                 }
+<a class="jxr_linenumber" name="L552" href="#L552">552</a>                 <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> MessagingException me)
+<a class="jxr_linenumber" name="L553" href="#L553">553</a>                 {
+<a class="jxr_linenumber" name="L554" href="#L554">554</a>                     <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/mail/EmailException.html">EmailException</a>(me);
+<a class="jxr_linenumber" name="L555" href="#L555">555</a>                 }
+<a class="jxr_linenumber" name="L556" href="#L556">556</a>             }
+<a class="jxr_linenumber" name="L557" href="#L557">557</a>         }
+<a class="jxr_linenumber" name="L558" href="#L558">558</a>         <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.text) &amp;&amp; EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.html))
+<a class="jxr_linenumber" name="L559" href="#L559">559</a>         {
+<a class="jxr_linenumber" name="L560" href="#L560">560</a>             <em class="jxr_comment">// EMAIL-142: if we have both an HTML and TEXT body, but no attachments or</em>
+<a class="jxr_linenumber" name="L561" href="#L561">561</a>             <em class="jxr_comment">//            inline images, the root container should have mimetype</em>
+<a class="jxr_linenumber" name="L562" href="#L562">562</a>             <em class="jxr_comment">//            "multipart/alternative".</em>
+<a class="jxr_linenumber" name="L563" href="#L563">563</a>             <em class="jxr_comment">// reference: http://tools.ietf.org/html/rfc2046#section-5.1.4</em>
+<a class="jxr_linenumber" name="L564" href="#L564">564</a>             <strong class="jxr_keyword">if</strong> (<strong class="jxr_keyword">this</strong>.inlineEmbeds.size() &gt; 0 || isBoolHasAttachments())
+<a class="jxr_linenumber" name="L565" href="#L565">565</a>             {
+<a class="jxr_linenumber" name="L566" href="#L566">566</a>                 <em class="jxr_comment">// If both HTML and TEXT bodies are provided, create an alternative</em>
+<a class="jxr_linenumber" name="L567" href="#L567">567</a>                 <em class="jxr_comment">// container and add it to the root container</em>
+<a class="jxr_linenumber" name="L568" href="#L568">568</a>                 bodyContainer = <strong class="jxr_keyword">new</strong> MimeMultipart(<span class="jxr_string">"alternative"</span>);
+<a class="jxr_linenumber" name="L569" href="#L569">569</a>                 <strong class="jxr_keyword">this</strong>.addPart(bodyContainer, 0);
+<a class="jxr_linenumber" name="L570" href="#L570">570</a>             }
+<a class="jxr_linenumber" name="L571" href="#L571">571</a>             <strong class="jxr_keyword">else</strong>
+<a class="jxr_linenumber" name="L572" href="#L572">572</a>             {
+<a class="jxr_linenumber" name="L573" href="#L573">573</a>                 <em class="jxr_comment">// no attachments or embedded images present, change the mimetype</em>
+<a class="jxr_linenumber" name="L574" href="#L574">574</a>                 <em class="jxr_comment">// of the root container (= body container)</em>
+<a class="jxr_linenumber" name="L575" href="#L575">575</a>                 rootContainer.setSubType(<span class="jxr_string">"alternative"</span>);
+<a class="jxr_linenumber" name="L576" href="#L576">576</a>             }
+<a class="jxr_linenumber" name="L577" href="#L577">577</a>         }
 <a class="jxr_linenumber" name="L578" href="#L578">578</a> 
-<a class="jxr_linenumber" name="L579" href="#L579">579</a>             <em class="jxr_comment">// EMAIL-104: call explicitly setText to use default mime charset</em>
-<a class="jxr_linenumber" name="L580" href="#L580">580</a>             <em class="jxr_comment">//            (property "mail.mime.charset") in case none has been set</em>
-<a class="jxr_linenumber" name="L581" href="#L581">581</a>             msgHtml.setText(<strong class="jxr_keyword">this</strong>.html, <strong class="jxr_keyword">this</strong>.charset, EmailConstants.TEXT_SUBTYPE_HTML);
-<a class="jxr_linenumber" name="L582" href="#L582">582</a> 
-<a class="jxr_linenumber" name="L583" href="#L583">583</a>             <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> InlineImage image : <strong class="jxr_keyword">this</strong>.inlineEmbeds.values())
-<a class="jxr_linenumber" name="L584" href="#L584">584</a>             {
-<a class="jxr_linenumber" name="L585" href="#L585">585</a>                 bodyEmbedsContainer.addBodyPart(image.getMbp());
-<a class="jxr_linenumber" name="L586" href="#L586">586</a>             }
-<a class="jxr_linenumber" name="L587" href="#L587">587</a>         }
-<a class="jxr_linenumber" name="L588" href="#L588">588</a> 
-<a class="jxr_linenumber" name="L589" href="#L589">589</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.text))
-<a class="jxr_linenumber" name="L590" href="#L590">590</a>         {
-<a class="jxr_linenumber" name="L591" href="#L591">591</a>             msgText = <strong class="jxr_keyword">new</strong> MimeBodyPart();
-<a class="jxr_linenumber" name="L592" href="#L592">592</a>             bodyContainer.addBodyPart(msgText, 0);
-<a class="jxr_linenumber" name="L593" href="#L593">593</a> 
-<a class="jxr_linenumber" name="L594" href="#L594">594</a>             <em class="jxr_comment">// EMAIL-104: call explicitly setText to use default mime charset</em>
-<a class="jxr_linenumber" name="L595" href="#L595">595</a>             <em class="jxr_comment">//            (property "mail.mime.charset") in case none has been set</em>
-<a class="jxr_linenumber" name="L596" href="#L596">596</a>             msgText.setText(<strong class="jxr_keyword">this</strong>.text, <strong class="jxr_keyword">this</strong>.charset);
-<a class="jxr_linenumber" name="L597" href="#L597">597</a>         }
-<a class="jxr_linenumber" name="L598" href="#L598">598</a>     }
-<a class="jxr_linenumber" name="L599" href="#L599">599</a> 
-<a class="jxr_linenumber" name="L600" href="#L600">600</a>     <em class="jxr_javadoccomment">/**</em>
-<a class="jxr_linenumber" name="L601" href="#L601">601</a> <em class="jxr_javadoccomment">     * Private bean class that encapsulates data about URL contents</em>
-<a class="jxr_linenumber" name="L602" href="#L602">602</a> <em class="jxr_javadoccomment">     * that are embedded in the final email.</em>
-<a class="jxr_linenumber" name="L603" href="#L603">603</a> <em class="jxr_javadoccomment">     * @since 1.1</em>
-<a class="jxr_linenumber" name="L604" href="#L604">604</a> <em class="jxr_javadoccomment">     */</em>
-<a class="jxr_linenumber" name="L605" href="#L605">605</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../org/apache/commons/mail/HtmlEmail.html">InlineImage</a>
-<a class="jxr_linenumber" name="L606" href="#L606">606</a>     {
-<a class="jxr_linenumber" name="L607" href="#L607">607</a>         <em class="jxr_javadoccomment">/** content id. */</em>
-<a class="jxr_linenumber" name="L608" href="#L608">608</a>         <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> String cid;
-<a class="jxr_linenumber" name="L609" href="#L609">609</a>         <em class="jxr_javadoccomment">/** &lt;code&gt;DataSource&lt;/code&gt; for the content. */</em>
-<a class="jxr_linenumber" name="L610" href="#L610">610</a>         <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> DataSource dataSource;
-<a class="jxr_linenumber" name="L611" href="#L611">611</a>         <em class="jxr_javadoccomment">/** the &lt;code&gt;MimeBodyPart&lt;/code&gt; that contains the encoded data. */</em>
-<a class="jxr_linenumber" name="L612" href="#L612">612</a>         <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> MimeBodyPart mbp;
+<a class="jxr_linenumber" name="L579" href="#L579">579</a>         <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.html))
+<a class="jxr_linenumber" name="L580" href="#L580">580</a>         {
+<a class="jxr_linenumber" name="L581" href="#L581">581</a>             msgHtml = <strong class="jxr_keyword">new</strong> MimeBodyPart();
+<a class="jxr_linenumber" name="L582" href="#L582">582</a>             bodyContainer.addBodyPart(msgHtml, 0);
+<a class="jxr_linenumber" name="L583" href="#L583">583</a> 
+<a class="jxr_linenumber" name="L584" href="#L584">584</a>             <em class="jxr_comment">// EMAIL-104: call explicitly setText to use default mime charset</em>
+<a class="jxr_linenumber" name="L585" href="#L585">585</a>             <em class="jxr_comment">//            (property "mail.mime.charset") in case none has been set</em>
+<a class="jxr_linenumber" name="L586" href="#L586">586</a>             msgHtml.setText(<strong class="jxr_keyword">this</strong>.html, <strong class="jxr_keyword">this</strong>.charset, EmailConstants.TEXT_SUBTYPE_HTML);
+<a class="jxr_linenumber" name="L587" href="#L587">587</a> 
+<a class="jxr_linenumber" name="L588" href="#L588">588</a>             <em class="jxr_comment">// EMAIL-147: work-around for buggy JavaMail implementations;</em>
+<a class="jxr_linenumber" name="L589" href="#L589">589</a>             <em class="jxr_comment">//            in case setText(...) does not set the correct content type,</em>
+<a class="jxr_linenumber" name="L590" href="#L590">590</a>             <em class="jxr_comment">//            use the setContent() method instead.</em>
+<a class="jxr_linenumber" name="L591" href="#L591">591</a>             <strong class="jxr_keyword">final</strong> String contentType = msgHtml.getContentType();
+<a class="jxr_linenumber" name="L592" href="#L592">592</a>             <strong class="jxr_keyword">if</strong> (contentType == <strong class="jxr_keyword">null</strong> || !contentType.equals(EmailConstants.TEXT_HTML))
+<a class="jxr_linenumber" name="L593" href="#L593">593</a>             {
+<a class="jxr_linenumber" name="L594" href="#L594">594</a>                 <em class="jxr_comment">// apply default charset if one has been set</em>
+<a class="jxr_linenumber" name="L595" href="#L595">595</a>                 <strong class="jxr_keyword">if</strong> (EmailUtils.isNotEmpty(<strong class="jxr_keyword">this</strong>.charset))
+<a class="jxr_linenumber" name="L596" href="#L596">596</a>                 {
+<a class="jxr_linenumber" name="L597" href="#L597">597</a>                     msgHtml.setContent(<strong class="jxr_keyword">this</strong>.html, EmailConstants.TEXT_HTML + <span class="jxr_string">"; charset="</span> + <strong class="jxr_keyword">this</strong>.charset);
+<a class="jxr_linenumber" name="L598" href="#L598">598</a>                 }
+<a class="jxr_linenumber" name="L599" href="#L599">599</a>                 <strong class="jxr_keyword">else</strong>
+<a class="jxr_linenumber" name="L600" href="#L600">600</a>                 {
+<a class="jxr_linenumber" name="L601" href="#L601">601</a>                     <em class="jxr_comment">// unfortunately, MimeUtility.getDefaultMIMECharset() is package private</em>
+<a class="jxr_linenumber" name="L602" href="#L602">602</a>                     <em class="jxr_comment">// and thus can not be used to set the default system charset in case</em>
+<a class="jxr_linenumber" name="L603" href="#L603">603</a>                     <em class="jxr_comment">// no charset has been provided by the user</em>

[... 200 lines stripped ...]


Mime
View raw message