Fri, 21 May 2010

3:06 PM - Mozilla Thunderbird bug

Unlike every other email program on the planet, Mozilla Thunderbird requires one to use mime related instead of mixed mode to embed images within email attachments using the cid stuff.  This has caused me great pain this week.  Outlook worked, iphones worked, windows mail in vista, web based mail, gmail, ... everything except Thunderbird. 

Our implementation sends embedded mails using the javamail api.  Use  final Multipart mp = new MimeMultipart("related");


        // now do the image file attachments
            Set keys;
            keys = images.keySet();

            for (Object key : keys)
            {
                String hashkey = (String) key;
                final MimeBodyPart mbp2 = new MimeBodyPart();
                final DataSource source = new FileDataSource( images.get( hashkey ) ) {

                    @Override
                    public String getContentType()
                    {
                        return "image/jpeg";
                    }
                };
                mbp2.setDataHandler( new DataHandler( source ) );
                mbp2.setHeader( "Content-ID", "<i" + hashkey + ">" );
                mbp2.setFileName( hashkey + ".jpg" );  // temporary hack
                mbp2.setDisposition( Part.INLINE );
                mp.addBodyPart( mbp2 );
            }

0 comments