How to: Export a Calendar using Payload Sharing
|Outlook Developer Reference|
Microsoft Office Outlook 2007 includes the ability to share calendar information with other users by using an iCalendar (.ics) file attached to a MailItem. The CalendarSharing object is used to both generate the iCalendar file from a folder containing calendar items and to generate the MailItem to which the iCalendar file is attached.
This sample uses the CalendarSharing item to share free/busy information for the next seven days with a single recipient:
It uses the GetCalendarExporter method of the Folder object to create a CalendarSharing object reference for the folder.
It then sets the following properties on the CalendarSharing object to restrict the range and level of information exported by the object:
- The CalendarDetail property is set to limit the information for each calendar item to free/busy information only.
- The StartDate and EndDate properties are set to restrict the calendar items included in the file to the next seven days.
- The RestrictToWorkingHours property is set to restrict the calendar items to those that fall within working hours.
- The IncludeAttachments property is set to exclude any attachments for calendar items exported by the object.
- The IncludePrivateDetails property is set to exclude the details of any private calendar items exported by the object.
It then calles the ForwardAsICal method of the CalendarSharing object to export the calendar items to an iCalendar file and create a MailItem object with the iCalendar file as an attachment. The olCalendarMailFormatDailySchedule constant of the olCalendarMailFormat enumeration is used with the ForwardAsICal method to indicate that the body of the MailItem should contain, in HTML format, free/busy information for the next seven days.