François, Can you give this a try?
ByteArrayDataSource mimePartDataSource = new ByteArrayDataSource(imgData, inboundMimeBodyPart.getContentType()); attachment.setDataHandler(new DataHandler(mimePartDataSource)); On Sat, Dec 5, 2009 at 1:47 AM, mably <[email protected]> wrote: > This code doesn't work anymore for me : > > public void test() throws Exception{ > > String from = "[email protected]"; > String to = "[email protected]"; > String subject = "Testing multipart email"; > String htmlText = "<h1>Hello</h1><img src=\"cid:image\">"; > byte[] imgData = this.obtainByteData( > "/com/mably/cms/themes/standard/resources/images/ > enveloppe.gif"); > > Properties props = new Properties(); > Session session = Session.getDefaultInstance(props, null); > > Message msg = new MimeMessage(session); > msg.setFrom(new InternetAddress(from)); > msg.addRecipient(Message.RecipientType.TO, new InternetAddress > (to)); > msg.setSubject(subject); > > Multipart mp = new MimeMultipart("related"); > > MimeBodyPart htmlPart = new MimeBodyPart(); > htmlPart.setContent(htmlText, "text/html"); > mp.addBodyPart(htmlPart); > > MimeBodyPart attachment = new MimeBodyPart(); > attachment.setFileName("test.gif"); > attachment.setContent(imgData, "image/gif"); > attachment.setHeader("Content-ID","<image>"); > mp.addBodyPart(attachment); > > msg.setContent(mp); > > Transport.send(msg); > } > > What needs to be changed ? > > Any help will be greatly appreciated. > > François > > -- > > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > > > -- Ikai Lan Developer Programs Engineer, Google App Engine -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
