Creating an Appointment
Creating an appointment is much like creating a message, which we did in Chapter 6. To create an appointment, get a reference to the folder in which you’d like to create the appointment, then call the Add method of the folder’s Messages collection. The syntax of the Add method is the same here as it is when creating an email message. (See Section 6.3 in Chapter 6.) Once the item is created, set its appointment-specific properties as desired and call the AppointmentItem object’s Update method to save the appointment in the message store. Example 8-2 demonstrates creating an appointment that begins at 10:00 on the morning of April 5, 2001, and ends that same morning at 10:30. Note in the example that the user’s time is being marked as busy, and also that the user will be reminded of the appointment 15 minutes prior to its start time.
Example 8-2. Creating an Appointment
' gCdoSession previously Dim'ed, Set, and loggon on with valid profile. 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 folder's Messages collection. Set CdoMessages = CdoFolder.Messages ' Add a new item to the Messages collection. Set CdoAppointmentItem = CdoMessages.Add ' Set the appointment's properties. With CdoAppointmentItem .Subject = "XYZ Company Proposal" .Text = "XYZ is coming to demonstrate their widgets." ...
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.