How To Access a CDO 1.21 Entry Identifier from CDOEX (298401)



The information in this article applies to:

  • Microsoft Exchange 2000 Server
  • Collaboration Data Objects for Exchange 2000
  • Collaboration Data Objects (CDO) 1.21

This article was previously published under Q298401

SUMMARY

The PR_ENTRYID property contains a MAPI entry identifier that is used to identify a particular MAPI object. This article demonstrates how to get the entry identifier of a message using Collaboration Data Objects for Exchange (CDOEX) and then use this identifier to open the message using CDO 1.21.

MORE INFORMATION

To run the sample code, follow these steps:
  1. In Microsoft Visual Basic, open a new Standard EXE project.
  2. Add a button to the default form and paste the following code in the button click event:
     Dim objCDOEXMsg As CDO.Message
     Dim strSvrName As String
     Dim strDomainName As String
     Dim strUserName As String
     Dim strMail As String
     Dim strMsgURL As String
     Dim byteArray As Variant
     Dim singleByte As Variant
     Dim byteString As String
     Dim EntryID As String
     Dim strIDProp  As String
     Dim objSession As MAPI.Session
     Dim objMsg As MAPI.Message
    
     strSvrName = "mango5"
     strDomainName = "mango5dm.microsoft.com"
     strUserName = "Administrator"
     strMail = "Test.eml"
     
     strMsgURL = "file://./backofficestorage/" & _
                 strDomainName & "/MBX/" & _
                 strUserName & "/inbox/" & strMail
                 
     'Open the message.
     Set objCDOEXMsg = CreateObject("CDO.Message")
     objCDOEXMsg.DataSource.Open strMsgURL
         
     'Convert the byte array in MAPI property PR_ENTRYID to a string.
     strIDProp = "http://schemas.microsoft.com/mapi/proptag/x0fff0102"
     byteArray = objCDOEXMsg.Fields(strIDProp).Value
     
     For Each singleByte In byteArray
         byteString = Hex(singleByte)
         If Len(byteString) < 2 Then
             byteString = "0" & byteString
         End If
         EntryID = EntryID & byteString
     Next
     
     Set objCDOEXMsg = Nothing
     
     'Log on via CDO 1.21.
     Set objSession = CreateObject("MAPI.Session")
     objSession.Logon ProfileInfo:=strSvrName & vbLf & strUserName
     'Get the message based on the message entry ID.
     Set objMsg = objSession.GetMessage(EntryID)
     MsgBox "Message Subject: " & objMsg.Subject
     
     objSession.Logoff
     Set objSession = Nothing
     Set objMsg = Nothing
    
    					
  3. Change strSvrName, strDomainName, strUserName, and strMail in the code accordingly.
  4. Make a reference to Microsoft CDO for Exchange 2000 Library and Microsoft CDO 1.21 library.
  5. Run the program and then click the button.
  6. Verify that the subject of the message is correct.

Modification Type:MinorLast Reviewed:8/24/2005
Keywords:kbhowto kbMsg KB298401