• Post Reply Bookmark Topic Watch Topic
  • New Topic

images in html email - Please Help  RSS feed

 
Divyajot Ahluwalia
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,
i have been trying to send emails with html content and images in such a manner that the images are attached and the images in the main email links to the attached image. i have tried the following code but i am unable to establish the link.
Please help
the code is:

// basic message has been created
MimeMultipart multipart = new MimeMultipart("related");
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart = new MimeBodyPart();
String htmlText = "<H1>Hello</H1>" +
"<img src=\"cid:memememe\">";
messageBodyPart.setContent(htmlText, "text/html");
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
URL aurl=new URL("http://www.google.com/");
URL burl=new URL(aurl,"logo.gif");
DataSource fds = new URLDataSource(burl);
messageBodyPart.setDataHandler(new DataHandler(fds));
messageBodyPart.setHeader("Content-ID","memememe");
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);
Transport.send(msg);
this is from a jsp page im trying to use
the final email has the image attached but does not show it in the final email's html content.
Please help
DS

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!