Hi Ikai,

Effectively the code you provided seems to work but not exactly as I
hoped.

Before 1.2.8, I was able to send an html email with inline images
using the previous code.

Now the image is sent as an external attachment.

It's really sad we can't send nice html messages with images anymore.

Do you know if it will work again anytime soon ?

Thanx again for your help.

François


On 8 déc, 02:54, "Ikai L (Google)" <[email protected]> wrote:
> 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%2B 
> > [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.


Reply via email to