网上用来读取outlook express的信息很少,又想来获得邮件信息便于分析;用了一种变通的办法.将outlook express的邮件信息导入outlook 2003再用程序来取得其中的信息.用c#实现.并用正则的方法提取了邮件内容中的邮件地址
有兴趣的网友共同研究
Outlook.ApplicationClass olApp = new Outlook.ApplicationClass();
Outlook.NameSpace ns = olApp.GetNamespace("MAPI");
Outlook.MAPIFolder selectFolder = null;
Outlook.MailItem mi = null;
// 获得收件箱信息
selectFolder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
this.label1.Text = "收件箱:共有" + selectFolder.Items.Count.ToString() + "封邮件";
this.label1.Refresh();
dt.Columns.Add("1", typeof(string));
dt.Columns.Add("2", typeof(string));
dt.Columns.Add("3", typeof(string));
dt.Columns.Add("4", typeof(string));
dt.Columns.Add("5", typeof(string));
DataRow dr = null;
string isread = "未读";
int i = 1;
foreach (object item in selectFolder.Items)
{
mi = item as Outlook.MailItem;
if (mi.UnRead == false) { isread = "已读"; }
dr = dt.NewRow();
dr["1"] = i.ToString();
dr["2"] = mi.Subject;
dr["3"] = mi.CreationTime.ToString();
dr["4"] = isread;
dr["5"] = mi.Body;
dt.Rows.Add(dr);
i++;
this.label3.Text ="正在读取:"+ i.ToString();
this.label3.Refresh();
}
this.dataGridView1.DataSource = dt;
源代码 ::http://download.csdn.net/source/2097751