メールの件名は中国語に変換されますが、ファイルに添付されたメールの内容は中国語または日本語に変換されず、??????? と表示されます。誰か助けてくれませんか?以下は私のコードです:
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);