Working with Calendar Items in PST File

Adding MapiCalendar to PST

Create New PST, Add Sub-folders and Messages 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:

  1. Create a MapiCalendar object.
  2. Set the MapiCalendar properties using a constructor and methods.
  3. Create a PST using the PersonalStorage.create() method.
  4. 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 code snippet below shows how to create a MapiCalendar and then add it to the Calendar folder of a newly created PST file.

Save Calendar Items from Outlook 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. It uses the PersonalStorage and MapiCalendar classes to get the calendar information.

Below are the steps to save the calendar items:

  1. Load the PST file in the PersonalStorage class.
  2. Browse the Calendar folder.
  3. Get the contents of the Calendar folder to get the message collection.
  4. Loop through the message collection.
  5. Call the PersonalStorage.extractMessage() method to get the contact information in the MapiCalendar class.
  6. Call the 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. If you open any ICS file in Microsoft Outlook, it will look like the one in the below screenshot.

Figure: Calendar item saved with Aspose.Email

Modify/Delete Occurrences from Recurrences