EntryID Property Example

This Visual Basic for Applications example uses the EntryID property to compare the entry ID of one message to the entry ID of a message returned by a search operation to determine whether the objects represent the same message.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myContacts = myNameSpace.GetDefaultFolder (olFolderContacts)
Set myItem1 = myOlApp.CreateItem(olContactItem)
myItem1.FirstName = "Brent"
Set myItem2 = myContacts.Items.Find("[FileAs] = _
    ""Jones"" and [FirstName] = ""Brent""")
If myItem1.EntryID = myItem2.EntryID Then
    MsgBox "These two message objects refer to the same message."
End If