Java mail API problem
Hi List,
I am using java mail API. I have to embed an image with my html content.
Here is the sample code that I am using for this.
MimeMultipart multipart = new MimeMultipart("related");
String imagefile = "E:/data//image002.gif";
try {
// Create your new message part
BodyPart messageBodyPart = new MimeBodyPart();
String htmlText = "Hello";
messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(htmlText,"text/html")));
multipart.addBodyPart(messageBodyPart);
// Create part for the image
messageBodyPart = new MimeBodyPart();
// Fetch the image and associate to part
DataSource fds = new FileDataSource(imagefile);
messageBodyPart.setDataHandler(new DataHandler(fds));
messageBodyPart.setHeader("Content-ID", "test_001");
messageBodyPart.setDisposition("inline");
message.setContent(multipart);
I am able to get an email as required with embedded image in OUTLOOK.
But It is not displaying images inline in gmail and yahoo.
I am unable to get where I am wrong?
Thanks in advance
source: http://www.thescripts.com/forum/thread591812.html

