电子邮件主题正在转换为中文,但文件中附带的电子邮件内容未转换为中文或日文,其显示为???????。有人能帮帮我吗? 以下是我的代码:
MimeMessage localMsg = null;
Properties localProp = null;
MimeBodyPart localMimeBodyPart = null;
Multipart localMultipart = null;
MimeMessage localMsg = null;
DataSource localDs = null;
Session localSession = Session.getDefaultInstance(localProp, null);
localMsg = new MimeMessage(localSession);
localMsg.setHeader("Content-Type", "text/html;charset=utf-8");
localMsg.setSubject(subjectArg, "UTF-8");
localMimeBodyPart = new MimeBodyPart();
localMimeBodyPart.setContent(bodyMsgArg, "text/html;charset=utf-8");
localMultipart = new MimeMultipart();
localMultipart.addBodyPart(localMimeBodyPart);
for (int localInt1 = 0; localInt1 < attachmentsArg.length; localInt1++)
{
if ((attachmentsArg[localInt1] != null))
{
localMimeBodyPart = new MimeBodyPart();
localDs = attachmentsArg[localInt1];
localMimeBodyPart.setDataHandler(new DataHandler( localDs));
localMimeBodyPart.setFileName(localDs.getName());
localMultipart.addBodyPart(localMimeBodyPart);
}
}
localMsg.setContent(localMultipart);
localMsg.setSentDate(new Date());
localMsg.saveChanges();
Transport.send(localMsg);