PRB: CDO (1.x) Returns Message Object instead of AppointmentItem Object (196508)
The information in this article applies to:
- Collaboration Data Objects (CDO) 1.2
- Collaboration Data Objects (CDO) 1.21
This article was previously published under Q196508 SYMPTOMS
With Microsoft Outlook, you can create folders to hold AppointmentItems.
However, if you use CDO (1.2, 1.21) to retrieve an AppointmentItem from these non-default Appointment folders, you will get back a CDO (1.x) Message object instead of an Appointment object and therefore you cannot access some AppointmentItem-specific properties such as Location, StartTime, and EndTime.
CAUSE
CDO (1.2, 1.21) only supports retrieving AppointmentItem objects from the Calendar folder of the default message store for a particular profile. Even though you can create other folders that can store AppointmentItems, you cannot retrieve an AppointmentItem (where the Class property of the object is 26) from that folder. You can only get a Message item (where the Class property of the object is three).
RESOLUTION
As long as you are not working within the context of a service application
or an Active Server Pages page, you can use the Microsoft Outlook object
model to work with appointments in folders other than the Calendar folder
for the default message store.
The following code retrieves an AppointmentItem from a folder named
HoldAppt, which is a subfolder of Personal Folders. This code assumes that
you have at least one appointment in this folder. To compile and run this
code, be sure that you have added a project reference to the Microsoft
Outlook 98 type library.
Sample Code
Private Sub Command1_Click()
Dim objOutlook As Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objExplorer As Outlook.Explorer
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim objItem As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
objNamespace.Logon ShowDialog:=True
' Top level folders.
Set colFolders = objNamespace.Folders
Set objFolder = colFolders.Item("Personal Folders")
' Navigate down one level.
Set colFolders = objFolder.Folders
Set objFolder = colFolders.Item("HoldAppt")
' Get the first AppointmentItem.
Set objItem = objFolder.Items(1)
' You can access any of the standard AppointmentItem properties,
' such as the following:
MsgBox objItem.Subject, 0, "Subject"
MsgBox objItem.Location, 0, "Location"
MsgBox objItem.Start, 0, "StartTime"
MsgBox objItem.End, 0, "End Time"
objNamespace.Logoff
End Sub
STATUS
This behavior is by design.
REFERENCES
Modification Type: | Minor | Last Reviewed: | 3/4/2004 |
---|
Keywords: | kbcode kbMsg kbprb KB196508 |
---|
|