Viewing Calendar Contents

Appointment and meeting information is retrieved in one of the following four ways:

  1. Iterate through the entire Messages collection of the calendar folder to process all AppointmentItem objects. The following code does this:

    ' gCdoSession previously Dim'ed, Set, and logged on.
    
    Dim CdoFolder As MAPI.Folder
    Dim CdoMessages As MAPI.Messages
    Dim CdoAppointmentItem As MAPI.AppointmentItem
    
    ' Get the user's Calendar folder.
    Set CdoFolder = gCdoSession.GetDefaultFolder(CdoDefaultFolderCalendar)
    
    ' Get the collection of appointments.
    Set CdoMessages = CdoFolder.Messages
    
    ' Loop for each appointment.
    For Each CdoAppointmentItem In CdoMessages
       '
       ' Code that does something with an AppointmentItem object
       '
    Next CdoAppointmentItem
  2. Apply a filter to the Messages collection, then iterate through the resulting members. This technique is described in the next section.

  3. Invoke the GetAssociatedAppointment method of the MeetingItem object. This was discussed earlier in this chapter under Section 8.2, in the discussion of the MeetingResponseStatus property of the AppointmentItem object.

  4. If the message ID of the appointment or meeting is known, invoke the GetMessage method of the Session object, as shown here:

    ' CdoSession previously Dim'ed, Set, and logged on.
    ' strMessageID previously Dim'ed and assigned.
    Dim CdoAppointmentItem As MAPI.AppointmentItem
    Set CdoAppointmentItem = CdoSession.GetMessage(strMessageID)

    The message ID can be found in the ID property of the AppointmentItem ...

Get CDO & MAPI Programming with Visual Basic: now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.