Platform SDK: Exchange 2000 Server

Specifying Exceptions to Recurring Appointments and Meetings

[This is preliminary documentation and subject to change.]

Exceptions are specific appointments that are added, modified, or deleted from the pattern of a recurring appointment or meeting. For example, if a recurring pattern generates a meeting that falls on a holiday, you can define an exception to that one instance of the recurring pattern.

CDO uses both IRecurrencePattern objects and IException objects to define exceptions to recurring appointments and meetings. The following table shows how each object can be used.

Object Type Action
IRecurrencePattern Add Adds a set of instances.
IRecurrencePattern Delete Deletes a set of instances.
IException Add Adds a single instance.
IException Delete Deletes a single instance.
IException Modify Changes the properties of one or more instances (equivalent to a Microsoft Outlook exception).

To create an exception to a recurring appointment or meeting

  1. Create the recurring appointment or meeting.
  2. Create an Exception object using the Add method on the Exceptions collection of the Appointment object, or create a RecurrencePattern object using the Add method on the RecurrencePatterns collection.
  3. Set the properties of the Exception or RecurrencePattern object to specify appointment instances being added, deleted, or modified.

The following code example creates a recurring meeting, deletes the meeting instance on Friday November 26, 1999, and adds a meeting instance on Monday November 29, 1999.

[Visual Basic]
Dim iAppt       As New Appointment
Dim Config      As New Configuration
Dim RRULE       As IRecurrencePattern
Dim iCalMsg     As CalendarMessage
Dim iAttendee   As New Attendee
Dim EXDATE      As IException
Dim RDATE       As IException
Dim CalendarURL As String

CalendarURL = "file://./backofficestorage/" & DomainName & "/MBX/" & UserName & "/calendar/"

'Set the configuration fields
Config.Fields(cdoSendEmailAddress) = UserName & "@" & DomainName
Config.Fields.Update
iAppt.Configuration = Config

'Set the first appointment properties
iAppt.StartTime = #10/15/1999 10:00:00 AM#
iAppt.EndTime = #10/15/1999 11:30:00 AM#
iAppt.Subject = "Department meeting"
iAppt.Location = "Oak Room"

'Create the RecurrencePattern object
Set RRULE = iAppt.RecurrencePatterns.Add("Add")

'Define the recurrence pattern
RRULE.Frequency = cdoWeekly  'use a weekly pattern
RRULE.Interval = 2  'every 2 weeks
RRULE.PatternEndDate = #12/24/1999 11:30:00 AM# 'the last appointment

'Delete the appointment instance on November 26
Set EXDATE = iAppt.Exceptions.Add("Delete")
'The ID is the start time of the instance being deleted
EXDATE.RecurrenceID = #11/26/1999 10:00:00 AM#

'Add an appointment instance on November 29
Set RDATE = iAppt.Exceptions.Add("Add")
RDATE.StartTime = #11/29/1999 10:00:00 AM#
RDATE.EndTime = #11/29/1999 11:30:00 AM#

'Add an attendee
Set iAttendee = iAppt.Attendees.Add
iAttendee.Address = "someone@" & DomainName
iAttendee.Role = cdoRequiredParticipant

'Create the calendar message and send it
Set iCalMsg = iAppt.CreateRequest
iCalMsg.Message.Send

'Save the appointment to the organizer's calendar
iAppt.DataSource.SaveToContainer CalendarURL