如何將使用Apache Commons Email生成的電子郵件的編碼更改爲UTF-8?我想根據接收者的語言發送我生成的電子郵件,我需要考慮日語和俄語。問題是:電子郵件類沒有提出一個UTF-8常數,我可以傳遞給Email.setCharset
方法。任何線索?Apache Commons Email和UTF-8
9
A
回答
9
是否有似乎是UTF_8恆定Apache的通用電子郵件API中:
UTF_8
static final String UTF_8
See Also:
Constant Field Values
All Known Implementing Classes:
Email, HtmlEmail, ImageHtmlEmail, MultiPartEmail, SimpleEmail
這是http://commons.apache.org/email/apidocs/src-html/org/apache/commons/mail/EmailConstants.html#line.38定義爲:
String UTF_8 = "utf-8";
見http://commons.apache.org/email/apidocs/org/apache/commons/mail/EmailConstants.html
2
如果你工作使用版本1.2,您可以創建自己的常量,直到該方法接受一個String並且如果不存在則拋出一個UnsupportedCharsetException支持JVM中的指定字符集。
如果可能的話,可以在Apache commons lang的CharEncoding類中使用UTF_8常量。
相關問題
- 1. 如何更改Apache Commons Email中的charset?
- 2. Apache Commons Email v1.1更改超時時間
- 3. Apache Karaf和Apache Commons Bundles
- 4. Apache Commons Validator和JUnit
- 5. javax.naming.NoInitialContextException Apache Commons api
- 6. 無法通過gmail使用Apache Commons Email發送電子郵件。
- 7. Apache Commons Email安裝在Eclipse中:無法解決
- 8. Apache Commons Email使用「普通gmail」,但不使用「Gmail for work」?
- 9. Apache FOP - PDF流式傳輸到Commons Email Attachment
- 10. 使用commons-email配置模擬郵件
- 11. Apache Commons Net FTPClient和listFiles()
- 12. Apache Commons Net Lib和min-/targetsdkversion
- 13. 使用Apache Commons VFS
- 14. Apache Commons FTPClient Loggin
- 15. sun.misc.BASE64到apache commons
- 16. apache commons lang StrTokenizer
- 17. Apache Commons JCI ReloadingClassLoader
- 18. Apache commons csv
- 19. 使用commons-configuration2和commons-beanutils-1.9和Apache spark 1.6
- 20. Apache Commons VFS:使用FTP
- 21. OSGi-ified Apache Commons Logging?
- 22. apache commons lang3 stringutils taglib
- 23. 關於Apache Commons EqualsBuilder和HashCodeBuilder和空值
- 24. Apache Commons FTP問題
- 25. Apache commons Fileupload vs Tomcat.util.http.fileupload
- 26. Apache Commons FileUpload OSGi包
- 27. java.lang.NoClassDefFoundError:org/apache/commons/collections/ReferenceMap
- 28. apache commons | pool或pool2
- 29. java.lang.NoClassDefFoundError:org/apache/commons/lang3/ObjectUtils
- 30. Apache commons untar:IllegalArgumentException與getNextTarEntry
如果我理解正確,那就是1.3-SNAPSOT版本。 –
您是否嘗試設置字符串值而不是引用常量? –
它與1.3-SNAPSHOT一起工作。我希望他們有一天會釋放它... –