public static void Run()
{
// ExStart:SaveCalendarItems
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Outlook();
// Load the Outlook PST file
PersonalStorage pst = PersonalStorage.FromFile(dataDir + "Sub.pst");
// Get the Calendar folder
FolderInfo folderInfo = pst.RootFolder.GetSubFolder("Inbox");
// Loop through all the calendar items in this folder
MessageInfoCollection messageInfoCollection = folderInfo.GetContents();
foreach (MessageInfo messageInfo in messageInfoCollection)
{
// Get the calendar information
MapiMessage calendar = (MapiMessage)pst.ExtractMessage(messageInfo).ToMapiMessageItem();
// Display some contents on screen
Console.WriteLine("Name: " + calendar.Subject);
// Save to disk in ICS format
calendar.Save(dataDir + @"\Calendar\" + calendar.Subject + "_out.ics");
}
// ExEnd:SaveCalendarItems
}
}