2011-09-09 25 views
1

我想提取Outlook中所有日曆中的所有項目。我已經使用我的默認日曆,但由於某些未知的原因,我無法獲得其他日曆項目。這是我迄今爲止所做的:處理outlook中的多個日曆

   Microsoft.Office.Interop.Outlook.Application oApp = null; 
       Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null; 
       Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null; 
       Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null; 

       oApp = new Microsoft.Office.Interop.Outlook.Application(); 
       mapiNamespace = oApp.GetNamespace("MAPI"); ; 
       CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); outlookCalendarItems = CalendarFolder.Items; 
       outlookCalendarItems.IncludeRecurrences = true; 

它從.NET: Get all Outlook calendar items。在這種情況下CalendarFolder.Folders是空的,有幫助嗎?我需要一個遍歷所有日曆的函數,用於用戶(不知道日曆的名稱)。

感謝

回答

0

試試這個:

Application outlook = new Application(); 
MAPIFolder calendars = (MAPIFolder)outlook.ActiveExplorer().Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar); 
      for (int i = 1; i <= calendars.Folders.Count; i++)