This documentation is archived and is not being maintained.

NameSpace.CompareEntryIDs Method

Office 2007
Returns a Boolean value that indicates if two entry ID values refer to the same Outlook item.

Version Information
 Version Added:  Outlook 2007


expression.CompareEntryIDs(FirstEntryID, SecondEntryID)

expression   An expression that returns a NameSpace object.


NameRequired/OptionalData TypeDescription
FirstEntryIDRequiredStringThe first entry ID to be compared.
SecondEntryIDRequiredStringThe second entry ID to be compared.

Return Value
True if the entry ID values refer to the same Outlook item; otherwise, False.


Entry identifiers cannot be compared directly because one object can be represented by two different binary values. Use this method to determine whether two entry identifiers represent the same object.


The following Visual Basic for Applications (VBA) example compares the entry identifier associated with the organizer of a specified AppointmentItem object with the entry identifier of a specified Recipient object, using the CompareEntryIDs method, and returns True if the organizer and the specified recipient represent the same user.

Visual Basic for Applications
Function IsRecipientTheOrganizer( _
    ByVal Appt As Outlook.AppointmentItem, _
    ByVal Recipient As Outlook.Recipient) As Boolean
    Dim objAddrEntry As Outlook.AddressEntry
    Dim objPropAc As Outlook.PropertyAccessor
    Dim strOrganizerEntryId As String
    Dim bytResult() As Byte
    Dim objRecipientUser As Outlook.ExchangeUser
    Dim objOrganizerUser As Outlook.ExchangeUser
    Dim blnReturn As Boolean
    'Property tag for Organizer EntryID

    ' Retrieve an AddressEntry object reference for the
    ' specified recipient.
    Set objAddrEntry = Recipient.AddressEntry

    ' If the address entry represents an Exchange user
    ' or Exchange remote user, retrieve an
    ' ExchangeUser object reference for the sender and
    ' compare the EntryID value of that object with
    ' the EntryID of the specified recipient.
    If objAddrEntry.AddressEntryUserType = _
    OlAddressEntryUserType.olExchangeUserAddressEntry _
    Or objAddrEntry.AddressEntryUserType = _
    OlAddressEntryUserType.olExchangeRemoteUserAddressEntry Then

        ' Attempt to retrieve an ExchangeUser
        ' object reference for the specified
        ' recipient.
        Set objRecipientUser = objAddrEntry.GetExchangeUser()
        If objRecipientUser Is Nothing Then
            ' An Exchange user could not be retrieved
            ' for the specified recipient.
            blnReturn = False
            ' Retrieve the EntryID property value of the organizer.
            ' The Organizer property of the AppointmentItem object only
            ' contains a string representation of the name of the
            ' organizer, so the PR_SENT_REPRESENTING_ENTRYID property value
            ' is instead retrieved, using the PropertyAccessor object
            ' associated with the appointment item.
            Set objPropAc = Appt.PropertyAccessor
            bytResult = objPropAc.GetProperty( _
            If Not IsEmpty(bytResult) Then
                ' Convert the binary value retrieved from the
                ' PR_SENT_REPRESENTING_ENTRYID property into
                ' a string value for comparison.
                strOrganizerEntryId = _
                ' Attempt to retrieve an ExchangeUser
                ' object reference for the organizer.
                Set objOrganizerUser = Appt.Application.Session. _
                If objOrganizerUser Is Nothing Then
                    ' An Exchange user could not be retrieved
                    ' for the organizer.
                    blnReturn = False
                    ' Compare the EntryIDs of the organizer
                    ' and the specified recipient.
                    blnReturn = Appt.Application.Session. _
                        CompareEntryIDs( _
                        objRecipientUser.ID, _
                End If
            End If
        End If
    End If
    ' Clean up
    Set objOrganizerUser = Nothing
    Set objRecipientUser = Nothing
    Set objAddrEntry = Nothing
    Set objPropAc = Nothing
    ' Return the results.
    IsRecipientTheOrganizer = blnReturn
    Exit Function
    Debug.Print Err.Number & " - " & Err.Description, _
        vbOKOnly Or vbCritical, _
    GoTo EndRoutine
End Function