Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

images in html email - Please Help

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");
messageBodyPart = new MimeBodyPart();
URL aurl=new URL("");
URL burl=new URL(aurl,"logo.gif");
DataSource fds = new URLDataSource(burl);
messageBodyPart.setDataHandler(new DataHandler(fds));
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

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic