Apache Commons Email和UTF-8

Ale*_*noy 9 java email utf-8 apache-commons-email

如何将使用Apache Commons Email生成的电子邮件的编码更改为UTF-8?我想根据收件人的语言发送我生成的电子邮件,我需要考虑日语和俄语.问题是:Email类没有提出我可以传递给该Email.setCharset方法的UTF-8常量.任何线索?

Rob*_*sch 11

在Apache Commons Email API中似乎有一个UTF_8的常量:

UTF_8

static final String UTF_8
See Also:
  Constant Field Values

All Known Implementing Classes:
  Email, HtmlEmail, ImageHtmlEmail, MultiPartEmail, SimpleEmail
Run Code Online (Sandbox Code Playgroud)

http://commons.apache.org/email/apidocs/src-html/org/apache/commons/mail/EmailConstants.html#line.38中定义如下:

String UTF_8 = "utf-8";
Run Code Online (Sandbox Code Playgroud)

请参阅http://commons.apache.org/email/apidocs/org/apache/commons/mail/EmailConstants.html