求助!关于JavaMail发送中文名附件乱码的问题
不知为什么发送的邮件中附件的中文名变成乱码,请问这个问题如何解决,谢谢!
下面是添加附件的代码段,需要的话,我给全部代码。qq: 11362918
// create and fill the first message part
MimeBodyPart mBodyContent = new MimeBodyPart();
if (content != null)
mBodyContent.setContent(content, messageContentMimeType);
else
mBodyContent.setContent("", messageContentMimeType);
mPart.addBodyPart(mBodyContent);
// attach the file to the message
if (attachedFiles != null) {
for (int i=attachedFiles.size()-1; i>=0; i--) {
String attachedFileName = (String) attachedFiles.elementAt(i);
MimeBodyPart mBodyPart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(basePath + attachedFileName);
mBodyPart.setDataHandler(new DataHandler(fds));
mBodyPart.setFileName(attachedFileName);
if(debug) {
System.out.println(attachedFileName);
System.out.println(mBodyPart.getFileName());
}
mPart.addBodyPart(mBodyPart);
}
}
msg.setContent(mPart);