ID: Q194806
The information in this article applies to:
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.
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.
<SCRIPT RunAt=Server Language=VBScript>
'--------------------------------------------------------------------
'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
</SCRIPT>
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
For more information on installing and using Microsoft Exchange Server Event Agents, please see the Agents.hlp file on the Microsoft Exchange Server CD-ROM.
Additional query words:
Keywords : kbCDO120 kbCDO121 kbMsg kbVBScript
Version : WINDOWS:1.2,1.21
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: December 2, 1998