Java 通过GAE向用户发送UTF-8编码的电子邮件和编码错误的字符
我有这个代码,它向用户发送激活电子邮件:Java 通过GAE向用户发送UTF-8编码的电子邮件和编码错误的字符,java,google-app-engine,android-studio,Java,Google App Engine,Android Studio,我有这个代码,它向用户发送激活电子邮件: public static void sendActivationEmail(User user) throws Exception { Properties props = new Properties(); Session session = Session.getDefaultInstance(props, null); ResourceBundle bundle = ResourceBundle.getBundle("pl
public static void sendActivationEmail(User user) throws Exception {
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
ResourceBundle bundle = ResourceBundle.getBundle("pl/hello/hello/resources/bundle", user.getLocale());
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(AaGAEAppTools.getAdminEmail(), "Hello"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(user.getEmail(), user.getName()));
msg.setSubject(bundle.getString("activation.email.title"));
Multipart mp = new MimeMultipart();
MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(getActivationEmailHtml(user), "text/html; charset=utf-8");
mp.addBodyPart(htmlPart);
msg.setContent(mp);
Transport.send(msg);
}
public static String getActivationEmailHtml(User user) throws Exception {
Locale locale = user.getLocale();
ResourceBundle b = ResourceBundle.getBundle("pl/aprilapps/gameofwords/resources/bundle", locale);
InputStream is = new FileInputStream("WEB-INF/emails/activation_template.html");
StringWriter writer = new StringWriter();
IOUtils.copy(is, writer, "UTF-8");
return writer.toString();
}
然而,当我在Android Gmail客户端上阅读它时,波兰字符的编码是错误的
我查过:
- Android studio编码设置,并将全部设置为UTF-8
- ResourceBundle文件编码,也是UTF-8