当我发送当前来自GAE的电子邮件时,我收到带有引用可打印内容传输编码的电子邮件。我希望将其设置为base64。除了在我收到电子邮件时不显示图像时,将显示引用的可打印内容。就像现在我的html看起来像这样:
String base64StringImg = Base64.encode(my byte array);
StringBuilder htmlBody = new StringBuilder();
htmlBody.append("<html>");
htmlBody.append("<body>");
htmlBody.append("<img src='data:image/png;base64,");
htmlBody.append(base64StringImg);
htmlBody.append("'/>");
htmlBody.append("<br/><br/>");
htmlBody.append("Hello " + name);
htmlBody.append("</body>");
htmlBody.append("</html>");
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromUser));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
message.setSubject(subject);
Multipart mp = new MimeMultipart();
BodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(htmlBody.toString(), "text/html; charset=UTF-8");
mp.addBodyPart(htmlPart);
message.setContent(mp);
Transport.send(message);
如何在GAE中发送带有图像的html电子邮件?我已经阅读了以下两个错误/功能请求,这些请求表明存在限制。
http://code.google.com/p/googleappengine/issues/detail?id=198 http://code.google.com/p/googleappengine/issues/detail?id=965
答案 0 :(得分:0)
HTML嵌入式图片似乎在电子邮件客户端中得不到支持:http://www.campaignmonitor.com/blog/post/1761/embedding-images-in-email/
支持的是附加到电子邮件的图片HTML图片:http://www.campaignmonitor.com/blog/post/1759/embedding-images-revisited/
但是,正如您在issue的链接中所指出的那样,第二个选项在GAE中得不到支持。您可以尝试的是手动创建第二个链接中显示的邮件内容。