如何在不将附件上传到内存的情况下解析EML文件? [英] how can i parse EML files, without uploading the attachments to memory?

查看:81
本文介绍了如何在不将附件上传到内存的情况下解析EML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下是否有一个推荐的库可以解析eml文件,但是不解析附件?

我希望能够从中构造没有附件的电子邮件,以后再进行另一项工作-提取附件.

感谢

I wanted to ask if there''s a recommended library that parses eml files, but doesn''t parse the attachments?

i want to be able to construct email messages from it, without attachments, and later, with another job - extract the attachments.

thanks

推荐答案

"EML"仅是许多电子邮件应用程序和某些Web浏览器(例如Mozilla Seamonkey套件)所使用的文件名的常规约定.请勿在其电子邮件应用程序中使用它,而是查看它们).这些文件没有任何特殊的文件格式.只需将所有包含在电子邮件中的数据作为邮件传递代理发送和接收的数据包( http://en.wikipedia.org/wiki/Mail_delivery_agent [ ^ ]),POP3,IMAP服务器等.

如果仅使用文本编辑器打开此文件,您将非常清楚文件中的内容:标题和多部分消息中的某些部分".您可能希望某些部分可以以更易于理解的形式呈现给您,例如HTML,但您并未告诉我们您打算如何使用它.

如果尝试找到附件",您会发现没有任何东西是附件"的;附件只是是消息中嵌入的另一个消息部分(因此,由于某些历史原因,我不知道为什么将其称为附件"),带有"Content-disposition:附件",还可以选择文件名:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html [ ^ ].

基本上,它旨在包含任意格式的任意文件.电子邮件程序通常提供将其保存"为单独文件的可能性.我想知道解析它们是什么意思,因此不解析附件"可能是唯一合理的选择.

要将消息解析为其组件,请尝试使用此MailUtilities库:
http://mailutilities.codeplex.com/ [ ^ ].

—SA
"EML" is nothing more then a usual convention on the file names used by many e-mail applications and some Web browsers (like Mozilla Seamonkey suite which does not use it in its e-mail application but view them). Those files do not have any special file format. The simply have all the data which is contained in the e-mail message, as a package sent and received by Mail Delivery agents (http://en.wikipedia.org/wiki/Mail_delivery_agent[^]), POP3, IMAP servers, etc.

If you simply open this file with a text editor, you will have a pretty good idea what''s in it: headers and, optionally, some "parts", in a multipart messages. You might wish that some of the parts could be presented to you in a more human-readable form, such as HTML, but you did not tell us what would you like to do with it.

If try to find "attachment", you will see that there is nothing which is "attached"; an attachment is merely yes another message part embedded in the message (so I don''t know why it was called "attachment", perhaps by some historical reasons) with "Content-disposition: attachment" and optionally, a file name:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html[^].

Basically, it is designed to include arbitrary file in arbitrary formats. E-mail programs usually offers a possibility to "save" them as separate files. I wonder what would you mean by parsing them, so not parsing "attachments" is probably the only reasonable option.

To parse a message into its components, try to use this MailUtilities library:
http://mailutilities.codeplex.com/[^].

—SA


这篇关于如何在不将附件上传到内存的情况下解析EML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆