Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

outlook doesn't show text part for multiPart email.

843830May 10 2004 — edited Oct 11 2006

Hello,

I am trying to send an email with text content and html attachment, and the html has images with it. I want both the text and html.

The code works when I send the email to yahoo. It does display both text and html attachment. But when I send the email to outlook, the text part is gone and it only display the html. Outlook does indicate the email has attachment. But I can only save the image not the html. And the outlook email header does indicate it contains a text part.

Anyone encounter the same problem? I really appreciate it if anyone can point out what I am doing wrong here.

thanks.



Here is my code:
//should default to mixed subtype
MimeMultipart multipart1 =new MimeMultipart();

BodyPart part=new MimeBodyPart();
part.setContent("this is email body text\n and a lot of content.","text/plain");
multipart1.addBodyPart(part);

MimeMultipart multipart = new MimeMultipart("related");
BodyPart messageBodyPart = new MimeBodyPart();
String htmlText = "<H1>Hello</H1>" +"<img src=\"cid:memememe\">";
messageBodyPart.setContent(htmlText, "text/html");
multipart.addBodyPart(messageBodyPart);

BodyPart messageBodyPart1 = new MimeBodyPart();
DataSource fds = new FileDataSource("image.jpg");
messageBodyPart1.setDataHandler(new DataHandler(fds));
messageBodyPart1.setHeader("Content-ID","<"+"memememe"+">");
multipart.addBodyPart(messageBodyPart1);

MimeBodyPart mbp = new MimeBodyPart();
mbp.setContent(multipart);
multipart1.addBodyPart(mbp);

message.setContent(multipart1);

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 8 2006
Added on May 10 2004
6 comments
1,466 views