C#操作Outlook

//引用Microsoft.Office.Interop.Outlook.dll
using Outlook = Microsoft.Office.Interop.Outlook;
using Microsoft.Office.Interop.Outlook;

        Outlook.Application myOutlookApp = new Outlook.Application();
        Outlook.NameSpace myNameSpace = myOutlookApp.GetNamespace("MAPI");
        Outlook.MAPIFolder myFolderInbox = myNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox);//获取收件箱对象,如获取其他箱可在参数中控制
        Outlook.MAPIFolder myFolder = myFolderInbox.Folders["APPLY"];//“APPLY”为收件箱下的一个文件夹
        foreach (object item in myFolder.Items)//遍历邮件
        {
           var mi = item as Outlook.MailItem;
            Console.WriteLine(mi.Subject);//邮件主题
            Console.WriteLine(mi.CreationTime);//接收时间
        }
上一篇:C#读取excel某列数据


下一篇:.Net DataTable导出到Excel