Platform SDK: Exchange 2000 Server

Canceling an Appointment

[This is preliminary documentation and subject to change.]

To cancel an appointment, you delete the appointment from the calendar folder. It’s a good idea to verify that you are deleting an appointment and not a meeting. Unlike Microsoft® Outlook®, CDO does not warn you to notify attendees when the item you are deleting has attendees. If the object being deleted has attendees, it is a meeting; see Canceling a Meeting.

The basic process for canceling an appointment is as follows:

  1. Open the calendar folder using an ADODB record set. Use the adOpenStatic and adLockOptimistic options on the Open method to enable deleting members of the record set.
  2. Locate the appointment you want to delete. Open the appointment and check the attendee count to verify that there are no other attendees.
  3. Delete the appointment using the Recordset.Delete method.

The following code example gets all of the appointments in the calendar of a specific user for all appointments with the subject "Documentation Review Meeting." It then verifies that the appointment has no other attendees, and deletes it.

[Visual Basic]
Dim CalendarURL As String
Dim ItemURL     As String
Dim Rs          As New ADODB.Recordset
Dim Rec         As New ADODB.Record
Dim iAppt       As New Appointment
Dim iAtnds      As CDO.IAttendees

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

'Open a record set for the specified items in the calendar folder
Rec.Open CalendarURL
Set Rs.ActiveConnection = Rec.ActiveConnection
Rs.Source = "SELECT ""DAV:href"", ""urn:schemas:httpmail:subject"" " & _
  "FROM scope('shallow traversal of """ & CalendarURL & """')" & _
  "WHERE (""urn:schemas:httpmail:subject"" = 'Documentation Review Meeting')"
Rs.Open , , adOpenStatic, adLockOptimistic

'Enumerate the record set and delete each appointment found
Rs.MoveFirst
Do Until Rs.EOF
  'Verify there are no attendees by checking attendee count
  ItemURL = Rs.Fields(CdoDAV.cdoHref).Value
  iAppt.DataSource.Open ItemURL
  Set iAtnds = iAppt.Attendees
  'If attendee count = 1, delete this appointment
  If iAtnds.Count = 1 Then
    Rs.Delete
  End If
Rs.MoveNext
Loop