您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

我可以在C#中读取Outlook(2003/2007)PST文件吗?

我可以在C#中读取Outlook(2003/2007)PST文件吗?

Outlook Interop库不仅用于加载项。例如,它可用于编写仅读取您所有Outlook联系人的控制台应用程序。我非常确定标准的Microsoft Outlook Interop库将允许您阅读邮件-尽管它可能会在Outlook中引发安全提示用户必须单击该提示

:实际使用Outlook Interop实现邮件阅读取决于您对“独立”的定义。Outlook Interop库要求在客户端计算机上安装Outlook才能正常运行。

// Dumps all email in Outlook to console window.
// Prompts user with warning that an application is attempting to read Outlook data.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace OutlookEmail
{
class Program
{
    static void Main(string[] args)
    {
        Outlook.Application app = new Outlook.Application();
        Outlook.NameSpace outlookNs = app.GetNamespace("MAPI");
        Outlook.MAPIFolder emailFolder = outlookNs.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderIn@R_739_2419@);

        foreach (Outlook.MailItem item in emailFolder.Items)
        {
            Console.WriteLine(item.SenderEmailAddress + " " + item.Subject + "\n" + item.Body);
        }
        Console.ReadKey();
    }
}
}
c# 2022/1/1 18:16:46 有344人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶