从 .EML 文件中检索电子邮件信息 [英] Retrieve Email Information from .EML Files

查看:23
本文介绍了从 .EML 文件中检索电子邮件信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

我搜索了一些源代码,但找不到任何源代码,除了这个 是否可以在 .net 中读取 .eml 文件但是没有源码,比较有用.

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

推荐答案

参考以下链接紧急:

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;
}

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

You can also get help for elm parsing from:

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

这也是有用的教程:

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

这篇关于从 .EML 文件中检索电子邮件信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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