开发者

How to setsubject in base64 encoding in mimemessage

开发者 https://www.devze.com 2023-01-08 13:12 出处:网络
While i send mail using javamail API i set the subject likr this msg.setSubject(subject,charset); But this setsubject method encode subject only in Quoted-printable encoding.

While i send mail using javamail API i set the subject likr this

msg.setSubject(subject,charset);

But this setsubject method encode subject only in Quoted-printable encoding. But i want t开发者_如何学Co setsubject in base64 encoding.

For Example:

Expected result: =?big5?B?............?=

result obtained: =?big5?Q?.............?=

please help me. Thanks in advance


You can encode and set subject header explicitly:

message.setHeader("Subject", MimeUtility.encodeText("Тема.", "utf-8", "B"));

Result:

Subject: =?utf-8?B?0uXs4C4=?=

But notice, that if your subject has only ASCII characters, it will NOT be encoded.

message.setHeader("Subject", MimeUtility.encodeText("Subject.", "utf-8", "B"));

Result:

Subject: Subject.
0

精彩评论

暂无评论...
验证码 换一张
取 消