小编jgo*_*222的帖子

在 C# 中从 Outlook 添加文件夹到 pst 文件

我一直在尝试找到一种从 C# 将文件夹添加到 pst 文件的方法

我已经尝试了一大堆代码来尝试让它工作,这似乎是最有可能正确的代码(因为它是 MSDN 上的内容),但仍然不起作用

Main {

Outlook._Application OutlookObject = new Outlook.Application();
            Outlook.Store NewPst = null;
           // create the pst file
            string pstlocation = "C:\\Users\\Test\\Desktop\\PST\\Test.pst";
            try
        {
            OutlookObject.Session.AddStore(pstlocation);

            foreach (Outlook.Store store in OutlookObject.Session.Stores)
            {
                if (store.FilePath == pstlocation)
                {
                    // now have a referance to the new pst file
                    NewPst = store;
                    Console.WriteLine("The Pst has been created");
                }
            }
        }
        catch
        { }
        // create a folder or subfoler in pst
        Outlook.MAPIFolder NewFolder;

        NewFolder = NewPst.Session.Folders.Add("New Test …
Run Code Online (Sandbox Code Playgroud)

.net c# outlook

2
推荐指数
1
解决办法
4166
查看次数

标签 统计

.net ×1

c# ×1

outlook ×1