Working with Calendar Items in PST File
Adding MapiCalendar to PST
Create a New PST File and Add Subfolders showed how to create a PST file and add a subfolder to it. With Aspose.Email you can add MapiCalendar to the Calendar subfolder of a PST file that you have created or loaded. Below are the steps to add MapiCalendar to a PST:
- Create a MapiCalendar object.
- Set the MapiCalendar properties using a constructor and methods.
- Create a PST using the PersonalStorage.Create() method.
- Create a pre-defined folder (Calendar) at the root of the PST file by accessing the root folder and then calling the AddMapiMessageItem() method.
The following code snippet shows you how to create a MapiCalendar and then add it to the calendar folder of a newly created PST file.
Save Calendar Items from PST to Disk in ICS Format
This article shows how to access calendar items from an Outlook PST file and save the calendar to disk in ICS format. Use the PersonalStorage and MapiCalendar classes to get the calendar information. Below are the steps to save calendar items :
- Load the PST file in the PersonalStorage class.
- Browse the Calendar folder.
- Get the contents of the Calendar folder to get the message collection.
- Loop through the message collection.
- Call PersonalStorage.ExtractMessage() method to get the contact information in the MapiCalendar class.
- Call the MapiCalendar.Save() method to save the calendar item to disk in ICS format.
The program below loads a PST file from disk and saves all the calendar items in ICS format. The ICS files can then be used in any other program that can load the standard ICS calendar file. Opened in Microsoft Outlook, an ICS file looks like the one in the below screenshot.
|The following code snippet shows you how to export the calendar items from Outlook PST to ICS format.|
Modify/Delete Occurrences from Recurrences
Exceptions can be added to existing recurrences using Aspose.Email for .NET API. The following code sample illustrates the usage of this feature.