我写了下面的代码
MimeMultipart multipart = new MimeMultipart("related");
// first part (the html)
BodyPart messageBodyPart = new MimeBodyPart();
String htmlText =
"<img src=\"cid:image\"\\>\n"+
"<div style=\"position:absolute; left: 150px; top: 298px; width: 248px;\">hello</div>\n"+
"<div style=\"position:absolute; left: 176px; top: 349px; width: 225px;\">hello</div>\n"+
"<div style=\"position:absolute; left: 185px; top: 401px; width: 216px;\">hello</div>\n"+
"<div style=\"position:absolute; left: 167px; top: 514px; width: 232px;\">hello</div>\n";
messageBodyPart.setContent(htmlText, "text/html");
// add it
multipart.addBodyPart(messageBodyPart);
// second part (the image)
messageBodyPart = new MimeBodyPart();
DataSource fds = new FileDataSource("D://a1.jpg");
messageBodyPart.setDataHandler(new DataHandler(fds));
messageBodyPart.setHeader("Content-ID","<image>");
// add it
multipart.addBodyPart(messageBodyPart);
// put everything together
msg.setContent(multipart);
bus.sendMessage(msg, address);
一切正常,电子邮件也正在发送,唯一的问题是div
元素应该在图像上方..但是在收到的电子邮件中,位置:电子邮件的绝对部分被省略了..
有什么帮助吗?