C#结合LumiSoft.Net.dll读取Outlook邮件(.eml格式邮件)

如果直接从Outlook(或者微软的其它邮件客户端如:Outlook Express、Windows Live Mail)的邮件文件(.eml格式)中提取各种电子邮件内容,使用LumiSoft.Net.dll(下载地址:http://www.lumisoft.ee/lsWWW/Download/Downloads/Net/)是一个不错的方法。

见下面的代码,很简单的代码,提取test.eml文件,分别提取了标题、发送地址、内容和发送日期。如果需要提取一个邮件的多个内容,可以根据智能感知参考;提取多个邮件,用一个遍历的办法即可完成。

using System;
using LumiSoft.Net.Mime;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
              Parse();
             Console.ReadKey();

        }

        //use LumiSoft.Net.dll, can read all info of email from .eml file
        public static void Parse()
        {
                 Mime m = Mime.Parse("E:\\test.eml");
                 MimeEntity[] entity = m.MimeEntities;
                 var subject = entity[0].Subject.ToString();
                 var from = entity[0].From.ToAddressListString();
                 var body = m.BodyHtml;
                //var body = entity[1].DataText;
                var addedDate = entity[0].Date;
            
        }
    }
}

 

posted @ 2014-02-24 12:57  wusir  阅读(2337)  评论(0编辑  收藏  举报