获得作为winmail.dat收到的POP 3的电子邮件附件 [英] get email attatchment for POP 3 received as winmail.dat
本文介绍了获得作为winmail.dat收到的POP 3的电子邮件附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试从POP 3邮件中获取附件时,我将其获取为winmail.dat,而不是原始的附加文件名.如何获取原始文件名?
When I try to get attatchment from POP 3 mail, I am getting them as winmail.dat, not the original attached file name. How can I get the original file name?
for (int i = 0; i < multipart.getCount(); i++)
{
BodyPart bodyPart = multipart.getBodyPart(i);
if(!Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition()))
{
//do something
}
else
{
bodyPart.getFileName(); // here only get the winmail.dat
}
}
推荐答案
This is part of the Exchange Settings, and sadly you going to need to extract the original contents from the WinMail.dat using JTNEF.
"Java TNEF软件包是TNEF消息处理程序的开放源代码实现,可以将其用作命令行实用程序或集成到基于Java的邮件应用程序中以提取原始消息内容."
可以在JavaMail的第三方工具上找到.
This is found on the JavaMail's third party tools.
作为替代方案,并且看起来更简单的是 POI-HMEF
As alternative and what looks simpler is POI-HMEF
样品提取:
public void extract(String winmailFilename, String directoryName) throws Exception {
HMEFContentsExtractor ext = new HMEFContentsExtractor(new File(winmailFilename));
File dir = new File(directoryName);
File rtf = new File(dir, "message.rtf");
if(! dir.exists()) {
throw new FileNotFoundException("Output directory " + dir.getName() + " not found");
}
System.out.println("Extracting...");
ext.extractMessageBody(rtf);
ext.extractAttachments(dir);
System.out.println("Extraction completed");
}
There is also a sample for printing the contents here.
这篇关于获得作为winmail.dat收到的POP 3的电子邮件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文