我想阅读EML文件中的附件。 。我更喜欢将EML文件转换为MSG文件,以便重新使用编写的代码,这可能吗?如果没有,是否有办法从EML文件中读取附件?
答案 0 :(得分:1)
如果没有,是否有办法从EML文件中读取附件?
JavaMail支持读取EML文件(MIME类型message/rfc822
)。请参阅示例here。
然后提取附件like this。另请参阅this explanation。
答案 1 :(得分:0)
您可以使用Aspose.Email API来实现EML到MSG的转换以及从EML中提取附件。
从EML提取附件
//OrderWidget
screens.OrderWidget.include({
renderElement: function(){
this._super();
var self = this;
//CALL HERE orderline_remove with line parameter
//How get line parameter?
},
});
将EML转换为MSG
//Initialize and Load an existing EML file
MailMessage msg = MailMessage.load(dataDir + "EmailWithAttachment.eml", new EmlLoadOptions());
//Initialize AttachmentCollection object with MailMessage Attachments
AttachmentCollection attachments = msg.getAttachments();
//Iterate over the AttachmentCollection
for (int index = 0; index < attachments.size(); index++) {
//Initialize Attachment object and Get the indexed Attachment reference
Attachment attachment = (Attachment) attachments.get_Item(index);
//Display Attachment Name
System.out.println(attachment.getName());
//Save Attachment to disk
attachment.save(dataDir + "attachment_" + attachment.getName());
}
您可以进一步访问Working with MIME Messages以获取有关这方面的更多信息。
我与Aspose一起担任开发者布道者。