heike1 发表于 2015-9-13 12:51:20

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.Subject.ToString();
var from = entity.From.ToAddressListString();
var body = m.BodyHtml;
//var body = entity.DataText;
var addedDate = entity.Date;
}
}
}
  
页: [1]
查看完整版本: C#结合LumiSoft.Net.dll读取Outlook邮件(.eml格式邮件)