Dealing with multiple calendars in outlook
I want to extract all items in all my calendars in outlook. I've got it working with my default calendar, but for some unknown reason I can't get other calendars items. Here is what I have done so far:
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;
It's from .NET: Get all Outlook calendar items . In This case CalendarFolder.Folders is empty, any help? I need a function that iterates thru all calendars, for å user (not knowing the names of the calendars).
Thanks
Try this:
Application outlook = new Application();
MAPIFolder calendars = (MAPIFolder)outlook.ActiveExplorer().Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
for (int i = 1; i <= calendars.Folders.Count; i++)
精彩评论