C# 从 .EML 文件中检索电子邮件信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16013254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 23:42:47  来源:igfitidea点击:

Retrieve Email Information from .EML Files

c#emailsharepoint

提问by Nemo

I have a .eml files. What I want to do is to retrieve the From, To, Subject, Body & attachments(if any) from this .eml file and save to database. I need to do that in C# and without any third party applications.

我有一个 .eml 文件。我想要做的是从此 .eml 文件中检索 From、To、Subject、Body 和附件(如果有)并保存到数据库。我需要在 C# 中做到这一点,而不需要任何第三方应用程序。

I searched for some source code, but couldn't find any, except this Is it possible to read .eml files in .netBut there is no source code, which is more helpful.

我搜索了一些源代码,但没有找到,除了这个是否可以在.net中读取.eml文件但是没有源代码,这更有帮助。

采纳答案by Freelancer

Refer Following link urgently:

紧急参考以下链接:

http://www.codeproject.com/Articles/76607/Easily-Retrieve-Email-Information-from-EML-Files-R

http://www.codeproject.com/Articles/76607/Easily-Retrieve-Email-Information-from-EML-Files-R

protected CDO.Message ReadMessage(String emlFileName)
{
    CDO.Message msg = new CDO.MessageClass();
    ADODB.Stream stream = new ADODB.StreamClass();
    stream.Open(Type.Missing, ADODB.ConnectModeEnum.adModeUnknown, ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified, String.Empty, String.Empty);
    stream.LoadFromFile(emlFileName);
    stream.Flush();
    msg.DataSource.OpenObject(stream, "_Stream");
    msg.DataSource.Save();
    return msg;
}

You can also get help for elm parsing from:

您还可以从以下位置获得有关 elm 解析的帮助:

http://blog.onderweg.eu/2010/12/parsing-eml-files-in-c/

http://blog.onderweg.eu/2010/12/parsing-eml-files-in-c/

This is also useful tutorial:

这也是有用的教程:

http://www.emailarchitect.net/eagetmail/kb/csharp.aspx?cat=18

http://www.emailarchitect.net/eagetmail/kb/csharp.aspx?cat=18