Visual Basic Code of the Week (COTW)
Issue #129
Online Version at (paid subscribers only)
All content and source code is Copyright (c) 2000 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Issue topic: Outlook Calendar Access


Keep up-to-date on Microsoft's new .NET initiative, which includes VB7, VS7, ASP+, Web services, the new C# language, the Microsoft .NET framework including ADO+, and much more. Just click the link for a free subscription.

Extra CASH!

If you have any tips to contribute, email us at Be sure to include instructions and source code. For each tip received which gets published we will pay you $10 to $25 US Dollars.


In this Issue

In this issue we discuss how access the Outlook calendar appointments using the Outlook Object Model.

If you have any questions about using this module, let us know at


This class allows you to access the Outlook appointments which appear in the default calendar. The full object model for the AppointmentItem object is available at

The basic usage of this class is to set the StartDate and EndDate properties to control which appointments are returned and then call the GetAppointments method. This method will retrieve a collection with the appointments that start between StartDate and EndDate.


Public Property Let StartDate(dStart As Date)
Public Property Get StartDate() As Date

The beginning of the date range used to determine with appointments will be returned by the GetAppointments method.

Public Property Let EndDate(dEnd As Date)
Public Property Get EndDate() As Date

The end of the date range used to determine with appointments will be returned by the GetAppointments method.


Public Sub GetAppointments(colAppt As Collection)

This is the method that does most of the work. A collection object needs to be passed to hold all the appointments between the date range StartDate and EndDate. The objects which will be stored in the collection colAppt are AppointmentItem objects. You can refer to the Outlook Object Model documentation for complete details at

The Count property of the collection can be used to determine how many appointments were returned.

The appointments read by this method are the ones in the default calendar folder.

Sample Usage

This sample shows how to use the cOutlookCalendar class by retrieving all appointments between 9/1/2000 and 9/30/2000. This sample just prints out the starting date/time, duration (in minutes) and the subject of the appointment.

    Dim oc As New cOutlookCalendar
    Dim colAppt As New Collection
    Dim oAppt As AppointmentItem

    oc.StartDate = "9/1/2000"
    oc.EndDate = "9/30/2000"
    oc.GetAppointments colAppt

    ' Prints out the start time, duration and subject of the appointment
    ' Duration is in minutes
    For Each oAppt In colAppt
        Debug.Print oAppt.Start, oAppt.Duration, oAppt.Subject

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address:

This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945