IsSameAs Method (AddressEntry Object)

The IsSameAs method returns True if the AddressEntry object is the same as the AddressEntry object being compared against.

Syntax

objAddressEntry.IsSameAs(objAddrEntry2)

objAddressEntry
Required. This AddressEntry object.
objAddrEntry2
Required. The AddressEntry object being compared against.

Remarks

Two AddressEntry objects are considered to be the same if and only if they are instantiations of the same physical (persistent) object in the underlying messaging system. Two objects with the same value are still considered different if they do not instantiate the same physical object, for example if one is a copy of the other. In such a case IsSameAs returns False.

The IsSameAs method ultimately calls one of the MAPI CompareEntryIDs methods to determine if two objects are the same. This is necessary because, although MAPI requires all entry identifiers to be unique, it does not require two of them identifying the same object to be identical. A generic comparison of any two objects' unique identifiers is available with the Session object's CompareIDs method.

Example

This code fragment uses IsSameAs to verify that the sender of a message is the same messaging user as is found in the receiver's personal address book (PAB):

Dim objMessage As Message 
  Dim objSender As AddressEntry 
  Dim colAEs As AddressEntries 
  Dim objAEFilt As AddressEntryFilter 
  Dim objUser As AddressEntry 
  ' assume objMessage received without error 
  Set objSender = objMessage.Sender 
  ' construct sender's full address 
  strSender = objSender.Type & ":" & objSender.Address 
  ' get the Personal Address Book the easy way (1 = CdoAddressListPAB) 
  Set colAEs = objSession.GetAddressList(1).AddressEntries 
  Set objAEFilt = colAEs.Filter 
  objAEFilt.Address  = strSender ' look for sender's full address 
  For Each objUser in colAEs 
    If objUser.IsSameAs(objSender) Then 
      MsgBox "Sender found in PAB" 
    End If 
  Next