ID Property (AddressEntry Object)

ID Property (AddressEntry Object)

The ID property returns the unique identifier of the AddressEntry object as a string. Read-only.

Syntax

objAddressEntry.ID

Data Type

String

Remarks

MAPI assigns a permanent, unique identifier when an object is created. This identifier does not change from one MAPI session to another, nor from one messaging domain to another. However, MAPI does not require identifier values to be binary comparable. Accordingly, two identifiers can have different values, yet refer to the same object. In particular, one of them could be a short-term identifier and the other a long-term identifier; these are constructed using different formats.

MAPI compares identifiers with the CompareEntryIDs method, which takes into account the differences between identifier formats and returns True if the identifiers are assigned to the same object. CDO provides the CompareIDs method in the Session object, which furnishes the same functionality. For more information on identifiers, see "PR_ENTRYID" in the MAPI Programmer's Reference.

Although the AddressEntry and Recipient objects are not identical objects in the CDO Library, they represent the same underlying MAPI messaging user object, and the address entry's ID property is equal to the recipient's ID property. This can be used to advantage, for example, when adding an existing AddressEntry object to a Recipients collection. You can use the address entry's ID property as the entryID parameter to the Add method.

The ID property corresponds to the MAPI property PR_ENTRYID, converted to a string of hexadecimal characters. It can be rendered into HTML hypertext using the CDO Rendering ObjectRenderer object. To specify this, set the object renderer's DataSource property to this AddressEntry object and the property parameter of the RenderProperty method to CdoPR_ENTRYID.

Example

This code fragment copies information from an AddressEntry object to a Recipient object:

' Function: Recipients_Add_EntryID
' Purpose: Add a new recipient to the collection using AddressEntry ID
Function Recipients_Add_EntryID()
Dim strID As String          ' ID from Message.Sender
Dim strName As String        ' Name from Message.Sender
Dim objNewMsg As Message     ' new msg; set its recipient using ID
Dim objNewRecip As Recipient ' new msg recipient; set from ID, Name
' error handling
strID = objOneMsg.Sender.ID  'Address Entry object ID
strName = objOneMsg.Sender.Name
Set objNewMsg = objSession.Outbox.Messages.Add
If objNewMsg Is Nothing Then
    MsgBox "Could not create a new message"
    Exit Function
End If
objNewMsg.Subject = "Sample message from CDO Library"
objNewMsg.Text = "Called Recipients.Add method w/ entryID parameter"
Set objNewRecip = objNewMsg.Recipients.Add( _
                  entryID:=strID, _
                  Name:=strName)
If objNewRecip Is Nothing Then
    MsgBox "Could not create a new recipient"
    Exit Function
End If
objNewMsg.Update ' make sure new data get saved in MAPI
objNewMsg.Send showDialog:=False
MsgBox "Created a new message in the Outbox and sent it"
Exit Function
' error handling
End Function
 

See Also

Concepts

AddressEntry Object