Microsoft KB Archive/194806

= PRB: Message.Class Incorrect After Calling GetMessage =

ID: Q194806

The information in this article applies to:


 * Collaboration Data Objects (CDO), versions 1.2, 1.21

SYMPTOMS
When you put a script on an agent on a Calendar folder, to process appointments, the Message.Type correctly displays "IPM.Appointment", but the Message.Class property is incorrect on the messages when they are retrieved with GetMessage. Because the Class property is incorrect, you will only be able to use Collaboration Data Objects (CDO) Message Object properties and methods, instead of CDO AppointmentItem properties and methods.

RESOLUTION
Use the GetDefaultFolder to access the Calendar folder, then use a filter on the folder to find the desired message based on EntryID. The following code demonstrates the use of the GetDefaultFolder method to get access to an AppointmentItem.



'   'FILE DESCRIPTION: Sample using the GetDefaultFolder method. '

Option Explicit

'   ' Global Variables '

'   ' Event Handlers '

' DESCRIPTION: This event fired when a new message is added to the ' folder. Public Sub Folder_OnMessageCreated

Dim oFolder Dim oMsg Dim oMsgFilter Dim CDOPR_ENTRYID Dim CDOCalendar

'Script constants. CDOPR_ENTRYID = &H0FFF0102 CDOCalendar = 0

' Get the defualt Calendar folder. Set oFolder = EventDetails.Session.GetDefaultFolder(CDOCalendar)

' Check to see if we are using the Calendar. If EventDetails.FolderID = oFolder.ID Then Set oMsgFilter = oFolder.Messages.Filter oMsgFilter.Fields(CDOPR_ENTRYID) = EventDetails.MessageID Set oMsg = oFolder.Messages.GetFirst Set oMsgFilter = Nothing

' Check the message class ' AppointmentItem = 26 ' The Message.Type will return "IPM.Appointment", but ' if the message class is not equal to 26 (AppointmentItem) ' then the AppointmentItem properties and methods can't         ' be used.

Script.Response = "Message.Class = " & oMsg.class

' Do other processing here on the message. Else ' Folder is not default Calendar folder for the Mailbox End if

End Sub

' DESCRIPTION: This event fired when a message in the folder ' changes. Public Sub Message_OnChange End Sub

' DESCRIPTION: This event fires when a message is deleted from the ' folder. Public Sub Folder_OnMessageDeleted End Sub

' DESCRIPTION: This event fires when the timer on the folder expires. Public Sub Folder_OnTimer End Sub



MORE INFORMATION
The GetDefaultFolder method only returns the default folder of the specified type for the default store. Therefore, you will not be able to create or access items in any store except the default store when using this method.

The GetDefaultFolder method can have exactly one of the following parameters:

ObjectType Setting            Value      Default Folder Retrieved --

CdoDefaultFolderCalendar      0          Calendar CdoDefaultFolderContacts      5          Contacts CdoDefaultFolderDeletedItems  4          Deleted Items CdoDefaultFolderInbox         1          Inbox CdoDefaultFolderJournal       6          Journal CdoDefaultFolderNotes         7          Notes CdoDefaultFolderOutbox        2          Outbox CdoDefaultFolderSentItems     3          Sent Items CdoDefaultFolderTasks         8          Tasks