GetMessage Method (Session Object)

GetMessage Method (Session Object)

The GetMessage method returns an AppointmentItem, MeetingItem, or Message object from a MAPI message store.

Syntax

Set objMessage = objSession.GetMessage(messageID [, storeID] )

objMessage

On successful return, contains the AppointmentItem, MeetingItem, or Message object with the specified identifier. If the specified messageID does not exist, GetMessage returns CdoE_NOT_FOUND.

objSession

Required. The Session object.

messageID

Required. String. Specifies the unique identifier of the appointment, meeting, or message.

storeID

Optional. String. Specifies the unique identifier of the message store. The default value is an empty string, which corresponds to the default message store.

Remarks

The GetMessage method allows you to obtain directly any AppointmentItem, MeetingItem, or Message object for which you know the ID property. You do not have to find and open the folder containing the message or the InfoStore containing the folder.

If CDO 1.2.1 and Microsoft® Outlook® 98 are sharing a stored profile, GetMessage always returns a Message object, even if an AppointmentItem or MeetingItem object is specified by the messageID parameter. To avoid this behavior, the recommended procedure is to use different profiles for CDO and Outlook 98. You can do this by specifying separate stored profiles for each, or by supplying the ProfileInfo parameter in the Session object's Logon method.

Example

This code fragment displays the subject of a message from a MAPI message store:

' fragment from Session_GetMessage
' requires the parameter strMessageID;
' also uses strMessageStoreID if it is defined
If strMessageID = "" Then
    MsgBox ("Must first set string variable to message ID")
    Exit Function
End If
If strMessageStoreID = "" Then ' not present
    Set objOneMsg = objSession.GetMessage(strMessageID)
Else
    Set objOneMsg = objSession.GetMessage(messageID:=strMessageID, _
                                          storeID:=strMessageStoreID)
End If
 

See Also

Concepts

Session Object