JavaMail的Subject乱码问题
<br />在emial.setSubject("SmartDrive Mismatch Records Report");<br /> <br />之前如果没有设置System.setProperty("mail.mime.charset","UTF-8");<br /> <br />在Linux的系统上可能会出现乱码如下<br /> <br />=?ANSI_X3.4-1968?Q?Smart
在emial.setSubject("SmartDrive Mismatch Records Report");
之前如果没有设置System.setProperty("mail.mime.charset","UTF-8");
在Linux的系统上可能会出现乱码如下
=?ANSI_X3.4-1968?Q?SmartDrive_Mismatch_Records_Report_?=
这里小小的记录一下!
You using the JavaMail API (this is the case if you use JBoss Application Server) and you send mails with special characters like German umlauts ä,ü,ö or something else. The JavaMail Api checks the system property “file.encoding” and if set the property “mail.mime.charset”. If your program runs on a linux server like suse 10, the default charset is ANSI_X3.4-1968. In Mozilla Thunderbird you get rubbish in the subject line
=?ANSI_X3.4-1968?Q?Testmail_-_Best=3Ftigung_Ihrer_eMail-Adresse?=
To get a clean subject like “Testmail – Bestätigung Ihrer eMail Adresse”, you must use the charset Cp1252.
Just put this command in your java code:System.setProperty("mail.mime.charset","Cp1252");
更多推荐
所有评论(0)