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);