February, 2008

Accessing Calendar Programatically

The Calendar in Microsoft Outlook can be accessed through the Microsoft.Office.Interop.Outlook assembly, available for download here. The code to provide access to the MAPIFolder object representing the calendar is shown below, along with a demonstration on how to output the subject of each event.

MAPIFolder CalendarFolder = new Microsoft.Office.Interop.Outlook.ApplicationClass().Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
foreach (AppointmentItem Item in CalendarFolder.Items)
Console.WriteLine(Item.Subject);

Hopefully if I can get this all sorted out I will be releasing an application that uses this information in the near future, but right now thats really just for my personal reference or for anyone with no idea where to start looking (the API isn't very clearly covered by Microsoft).

Link to This Article | Comments (0)
Tags: .NET, Calendar, Office Interop