MimeMessage message = new MimeMessage(mailSession);
Multipart multipart = new MimeMultipart("alternative");
BodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(new String(messageHtml.getBytes("UTF8"),"ISO-8859-1"), "text/html");
multipart.addBodyPart(htmlPart);
message.setContent(multipart);
message.setFrom(new InternetAddress(from));
message.setSubject(subject, "UTF-8");
诀窍是将我的 html 从 UTF-8 转换(它来自我的 message_iw.properties 的方式),然后将其转换为 ISO 格式,这样就有无需设置任何标题。
3 years late, but if someone hits this one, I found the answer:
MimeMessage message = new MimeMessage(mailSession);
Multipart multipart = new MimeMultipart("alternative");
BodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(new String(messageHtml.getBytes("UTF8"),"ISO-8859-1"), "text/html");
multipart.addBodyPart(htmlPart);
message.setContent(multipart);
message.setFrom(new InternetAddress(from));
message.setSubject(subject, "UTF-8");
The trick was to convert my html from UTF-8 (the way it came from my message_iw.properties), and then transform it into ISO format, so that there's no need to set any headers.
发布评论
评论(2)
您是否正确设置了字符编码?
试试这个:
你可能需要utf-16,我记不起希伯来语的字符集是什么。
在这里试试 http://www.i18nguy.com/unicode/codepages.html
Are you setting the character encoding correctly?
try this:
you may need utf-16, cant remember what char set hebrew is on off the top of my head.
try here http://www.i18nguy.com/unicode/codepages.html
晚了 3 年,但如果有人遇到这个问题,我找到了答案:
诀窍是将我的 html 从 UTF-8 转换(它来自我的 message_iw.properties 的方式),然后将其转换为 ISO 格式,这样就有无需设置任何标题。
3 years late, but if someone hits this one, I found the answer:
The trick was to convert my html from UTF-8 (the way it came from my message_iw.properties), and then transform it into ISO format, so that there's no need to set any headers.