You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Ben Speakmon (JIRA)" <ji...@apache.org> on 2007/01/03 01:33:27 UTC

[jira] Commented: (EMAIL-22) [email] New embed method for HtmlEmail

    [ https://issues.apache.org/jira/browse/EMAIL-22?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12461877 ] 

Ben Speakmon commented on EMAIL-22:
-----------------------------------

This is the same issue as EMAIL-35, and there's a patch in there that adds this. It doesn't try to validate the DataSource, though -- perhaps it should. Thoughts?

> [email] New embed method for HtmlEmail
> --------------------------------------
>
>                 Key: EMAIL-22
>                 URL: https://issues.apache.org/jira/browse/EMAIL-22
>             Project: Commons Email
>          Issue Type: Bug
>         Environment: Operating System: other
> Platform: Other
>            Reporter: zarkon
>
> Hi!
> I've written a new "embed" method (simply but neccesary) for the HtmlEmail
> class:
>     public String embed(DataSource ds, String name) throws EmailException{
>     	
>          // verify that the DataSource is valid
>         try
>         {
>             if (ds == null || ds.getInputStream() == null)
>             {
>                 throw new EmailException("Invalid Datasource");
>             }
>         }
>         catch (IOException e)
>         {
>             throw new EmailException("Invalid Datasource");
>         }
>         MimeBodyPart mbp = new MimeBodyPart();
>         try
>         {
>             mbp.setDataHandler(new DataHandler(ds));
>             mbp.setFileName(name);
>             mbp.setDisposition("inline");
>             String cid = randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase();
>             mbp.addHeader("Content-ID", "<" + cid + ">");
>             this.inlineImages.add(mbp);
>             return cid;
>         }
>         catch (MessagingException me)
>         {
>             throw new EmailException(me);
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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