Platform SDK: Exchange 2000 Server

Processing a Calendar Message

[This is preliminary documentation and subject to change.]

When a meeting organizer sends a meeting request, Exchange stores the calendar message in the recipient’s inbox. Responses to meeting requests, meeting updates, and cancellations are all received as calendar messages in the inbox. You can use ADO and CDO to get calendar messages from the inbox and process them.

You can identify an item in an Exchange folder by the item's content class. The content class is a property of items in the Web Store. The content class of calendar messages is contained in the "DAV:contentclass" field of the message. All calendar messages have the content class "urn:content-classes:calendarmessage."

You typically open calendar messages using the ICalendarPart.GetUpdatedItem method. This method checks the Web Store to see if the meeting in the calendar message already exists. If the meeting already exists, the calendar message is probably an update to the meeting. The GetUpdatedItem method returns an Appointment object in memory that contains the most current meeting information, either from the Web Store or the calendar message. When you save the meeting, it overwrites the existing meeting in the Web Store.

Note   If the calendar part contains an exception to an existing recurring meeting, the GetUpdatedItem method returns the exception in memory. If you accept or decline the exception, the meeting response is based on the exception. However, when you call the IDataSource.Save method on the exception, it merges the exception into the master recurring meeting and saves the updated master to the Web Store.

This topic explains how to identify and open calendar messages. Other topics in this section explain how to process the calendar message once it has been opened.

To open calendar messages in the inbox

  1. Open the inbox folder using an ADODB record.
  2. Open an ADODB record set containing the items in the inbox. Use a select statement to include the item URL and content class in the record set. Specify a where clause to select just calendar messages. Be sure to open the record set using the adLockOptimistic option so that you can delete items from the inbox.
  3. Get the URL of the message from the record set, and then open the URL using a CDO Calendar Message object.
  4. Open each calendar part in the calendar parts collection using a CDO Appointment object and process the Appointment object as needed.
  5. Delete the calendar message from the inbox (optional).

The following code example gets all calendar messages from the inbox of a specific user. It prints the subject of each calendar part and deletes the message. Examples for other topics in this section show how to actually process the calendar parts.

[Visual Basic]
Dim InboxURL     As String
Dim CalendarURL  As String
Dim ItemURL      As String
Dim Rs           As New ADODB.Recordset
Dim Rec          As New ADODB.Record
Dim iCalMsg      As New CalendarMessage
Dim iCalPart     As ICalendarPart
Dim iAppt        As Appointment
Dim Index        As Integer
Dim ContentClass As String

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

'Open the record set for the calendar messages in the inbox folder
Rec.Open InboxURL
Set Rs.ActiveConnection = Rec.ActiveConnection
Rs.Source = "SELECT ""DAV:href"",""DAV:contentclass"" " & _
  "FROM scope('shallow traversal of """ & InboxURL & """')" & _
  "WHERE (""DAV:contentclass"" = 'urn:content-classes:calendarmessage')"
Rs.Open , , , adLockOptimistic

'Enumerate the record set and process each calendar message
Rs.MoveFirst
Do Until Rs.EOF
  'Open the calendar message
  ItemURL = Rs.Fields(CdoDAV.cdoHref).Value
  iCalMsg.DataSource.Open ItemURL
  'Get each calendar part
  For Index = 1 To iCalMsg.CalendarParts.Count
    Set iCalPart = iCalMsg.CalendarParts(Index)
    Set iAppt = iCalPart.GetUpdatedItem(CalendarURL)
    'Process the appointment as necessary
    Debug.Print "Subject: " & iAppt.Subject
  Next Index
  'Delete the calendar message from the inbox
  Rs.Delete
Rs.MoveNext
Loop