Adding a New Outlook Appointment (via Automation):   Return to List

' A reference must be set to the current version of Microsoft Outlook under TOOLS | REFERENCES (within the VBE).

' This next example illustrates how you can add a new appointment to the Microsoft Outlook Calendar folder.  Note the similarity between the example creating a new MailItem and this example; both examples use the CreateItem method of the Outlook application object.

Public Sub AddAppointment()
    Dim objOutlook As New Outlook.Application
    Dim objAppt As AppointmentItem
    Set objAppt = objOutlook.CreateItem(olAppointmentItem)
    With objAppt
        .Subject = "Lunch"' Appointment's Subject line
        .Start = #2/25/97 1:00:00 PM#' Appointment's starting time
        .End = #2/25/97 2:00:00 PM#' Appointment's ending time
        .Location = "Restaurant"' Appointment's location
        .ReminderSet = True' Set Reminder to 15 minutes
        .ReminderMinutesBeforeStart = 15' before the start of the appointment
        .Save' Save the appointment
    End With
    Set objAppt = Nothing
    Set objOutlook = Nothing
End Sub



Note to Webmaster