commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joel Gautschi <j...@gameoefter.org>
Subject [email] bad cid returned from embed in HtmlEmail?
Date Thu, 25 Sep 2003 13:04:33 GMT
hi,

the embed(URL url, String name) method of 
org.apache.commons.mail.HtmlEmail returns the cid for the embeded url.
the cid contains a random ascii string (containing chars like <,",', etc.).
of course it didn't worked in the email client if I used a cid 
containing char like <,",' that's why I tried to url encode (using 
java.net.URLEncoder). but it doens't worked also (at least not in the 
outlook and mozilla mail client).

that's why I changed the line

String cid = RandomStringUtils.randomAscii(10);

to

String cid = RandomStringUtils.randomAlphanumeric(10);

now it works.

but I wanted to ask if I understood sth wrong because I think there 
would be more uses than me how ran into this problem. If other users ran 
into the same problem we should fix the embed method. I don't know if my 
randomAlphanumeric(10) is a good solution.

joel
below: original embed method from org.apache.commons.mail.HtmlEmail.

---
     public String embed(URL url, String name) throws MessagingException
     {
         MimeBodyPart mbp = new MimeBodyPart();

         mbp.setDataHandler (new DataHandler(new URLDataSource(url)));
         mbp.setFileName(name);
         mbp.setDisposition("inline");
         String cid = RandomStringUtils.randomAscii(10);
         mbp.addHeader("Content-ID", cid);

         inlineImages.add(mbp);
         return mbp.getContentID();
     }
---


Mime
View raw message