是否可以使用C#读取.PST文件?我想将此作为一个独立的应用程序,而不是作为Outlook插件(如果可能的话).
如果已经看到类似于提及MailNavigator的其他 SO 问题 ,但我希望在C#中以编程方式执行此操作.
我查看了Microsoft.Office.Interop.Outlook命名空间,但它似乎只适用于Outlook插件.LibPST似乎能够读取PST文件,但这是在C中(对不起Joel,我毕业前没有学过C).
任何帮助将不胜感激,谢谢!
编辑:
谢谢大家的回复!我接受了Matthew Ruston的回答作为答案,因为它最终导致我找到了我正在寻找的代码.这是我工作的一个简单示例(您需要添加对Microsoft.Office.Interop.Outlook的引用):
using System;
using System.Collections.Generic;
using Microsoft.Office.Interop.Outlook;
namespace PSTReader {
class Program {
static void Main () {
try {
IEnumerable<MailItem> mailItems = readPst(@"C:\temp\PST\Test.pst", "Test PST");
foreach (MailItem mailItem in mailItems) {
Console.WriteLine(mailItem.SenderName + " - " + mailItem.Subject);
}
} catch (System.Exception ex) {
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
private static IEnumerable<MailItem> readPst(string pstFilePath, string pstName) {
List<MailItem> mailItems …
Run Code Online (Sandbox Code Playgroud)