Platform SDK: Exchange 2000 Server

Getting Appointments and Meetings from Folders in Exchange

[This is preliminary documentation and subject to change.]

Microsoft® Exchange 2000 Server stores appointments and meetings in a user's calendar folder or in a public folder. Using a CDO Appointment object, you can open, view, and modify appointments and meetings in the Web Store. Individual appointments and meetings are stored as single items in the Web Store.

Recurring appointments are expanded into individual instances when the calendar folder is queried in the Web Store. If you want to modify one or more instances of a recurring appointment, you can modify the master appointment. You can also modify the individual instances directly. The urn:schemas:calendar:instancetype field identifies master recurring appointments, recurring instances, single appointments, or exceptions to recurring appointments.

Although appointments and meetings can be stored in any Exchange folder, the Web Store expands only recurring appointments and meetings stored in calendar folders.

The process for getting appointments from a calendar folder is as follows:

  1. Open the calendar folder using an ADODB record.
  2. Open an ADODB record set containing the items in the calendar folder. Use a select statement to include the item URL and the appointment date or other desired fields in the record set. To expand recurring meetings, include a WHERE clause in the SELECT statement that specifies the range of dates where recurring instances are expanded.
  3. Enumerate the record set, and test each item's fields as appropriate.
  4. For appointments that match your selection criteria, get the URL from the record set, and then open the URL using a CDO Appointment object.
  5. Process the Appointment objects as needed.

The following code example lists appointments in the calendar folder of user12, on the Exchange 2000 Server exsvr3 in the exchange.microsoft.com domain. The code example selects appointments within a specific date range that have the subject "Department Meeting." It also prints the start and end time of the appointment, the subject, and the instance type.

[Visual Basic]
Dim CalendarURL    As     String
Dim ItemURL        As     String
Dim Rs             As New ADODB.Recordset
Dim Rec            As New ADODB.Record
Dim Conn           As New ADODB.Connection
Dim iAppt          As New Appointment
Dim dateStartDate  As     Date
Dim Subject        As     String

CalendarURL = "file://./backofficestorage/exchange.microsoft.com/MBX/user12/calendar/"

'Open a record set for the items in the calendar folder
Rec.Open CalendarURL
Set Rs.ActiveConnection = Rec.ActiveConnection
Rs.Source = "SELECT ""DAV:href"", " & _
                  " ""urn:schemas:httpmail:subject"", " & _
                  " ""urn:schemas:calendar:dtstart"", " & _
                  " ""urn:schemas:calendar:dtend"" " & _
            "FROM scope('shallow traversal of """ & CalendarURL & """') " & _
            "WHERE (""urn:schemas:calendar:dtstart"" >= CAST(""1999-08-01T08:00:00Z"" as 'dateTime')) " & _
            "AND (""urn:schemas:calendar:dtend"" <= CAST(""1999-09-01T08:00:00Z"" as 'dateTime'))" 
Rs.Open

'Enumerate the record set, checking each item's subject
Rs.MoveFirst
Do Until Rs.EOF
    'get the subject of each item
    Subject = Rs.Fields(CdoHTTPMail.cdoSubject).Value
    If Subject = "Department Meeting" Then
        'open appointment
        ItemURL = Rs.Fields(CdoDAV.cdoHref).Value
        iAppt.DataSource.Open ItemURL
        Debug.Print iAppt.StartTime & " - " & iAppt.EndTime
        Debug.Print "Subject: " & iAppt.Subject
        'print the type of appointment
        Select Case iAppt.Fields(CdoCalendar.cdoInstanceType).Value
            Case cdoSingle
                Debug.Print "Single appointment"
            Case cdoMaster
                Debug.Print "Master recurring appointment"
            Case cdoInstance
                Debug.Print "Instance of recurring appointment"
            Case cdoException
                Debug.Print "Exception to recurring appointment"
            Case Else
                Debug.Print "Unknown"
        End Select
    End If
    
    Rs.MoveNext
   
Loop