将EML转换为MSG-Java
我想从EML文件中读取附件。我更喜欢将EML文件转换为MSG文件,这样我就可以重复使用编写的代码,这可能吗?如果没有,是否有从EML文件读取附件的方法 如果没有,是否有从EML文件读取附件的方法 支持读取EML文件(MIME类型将EML转换为MSG-Java,java,aspose,msg,eml,Java,Aspose,Msg,Eml,我想从EML文件中读取附件。我更喜欢将EML文件转换为MSG文件,这样我就可以重复使用编写的代码,这可能吗?如果没有,是否有从EML文件读取附件的方法 如果没有,是否有从EML文件读取附件的方法 支持读取EML文件(MIME类型消息/rfc822)。参见示例 然后提取附件。另请参见。您可以使用Aspose.Email API实现EML到MSG的转换和从EML提取附件 从EML中提取附件 //Initialize and Load an existing EML file MailMessage
消息/rfc822
)。参见示例
然后提取附件。另请参见。您可以使用Aspose.Email API实现EML到MSG的转换和从EML提取附件 从EML中提取附件
//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());
}
有关这方面的更多信息,您可以进一步访问
我与Aspose合作,担任开发人员宣传员
// Initialize and Load an existing EML file by specifying the MessageFormat
MailMessage eml = MailMessage.load(dataDir + "test.eml");
//Save the Email message to disk in Unicode format
eml.save(dataDir + "LoadingEMLSavingToMSG_out.msg", SaveOptions.getDefaultMsgUnicode());