Connect to Outlook calendar from C# using Interop

后端 未结 1 1040
旧时难觅i
旧时难觅i 2021-01-27 17:26

Ok I am trying to connect to an Outlook calendar from C# using the following code:

using Outlook = Microsoft.Office.Interop.Outlook;

Outlook.Application msOutlo         


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-27 17:58

    Are both calendars in the MAPI namespace? What if you loop through the namespaces to see if other ones have a calendar:

    Outlook.Application msOutlook = new Outlook.Application();
    Outlook.NameSpace session = msOutlook.Session;
    Outlook.Stores stores = session.Stores;
    foreach (Outlook.Store store in stores)
    {
        Outlook.MAPIFolder folder = store.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
    
        MessageBox.Show(folder.Name);
    }
    

    0 讨论(0)
提交回复
热议问题