Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 298401 - Last Review: February 22, 2007 - Revision: 2.5
How To Access a CDO 1.21 Entry Identifier from CDOEX
This article was previously published under Q298401
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.
To run the sample code, follow these steps:
- In Microsoft Visual Basic, open a new Standard EXE project.
- 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
- Change strSvrName, strDomainName, strUserName, and strMail in the code accordingly.
- Make a reference to Microsoft CDO for Exchange 2000 Library and Microsoft CDO 1.21 library.
- Run the program and then click the button.
- Verify that the subject of the message is correct.
APPLIES TO
- Microsoft Exchange 2000 Server Standard Edition
- Collaboration Data Objects for Exchange 2000
- Microsoft Collaboration Data Objects 1.21
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate