Partager via


GetRecipientFromID Method

Returns a Recipient object identified by the specified entry ID (if valid). This method is used for ease of transition between MAPI and OLE/Messaging applications and Microsoft Outlook.

expression**.GetRecipientFromID(EntryID)**

*expression    * Required. An expression that returns a NameSpace object.

EntryID    Required String. The EntryID of the recipient.

Remarks

If a program tries to reference any type of recipient information by using the Outlook object model, a dialog box is displayed that asks you to confirm access to this information. You can allow access to the Address Book or recipient information for up to ten minutes after you receive the dialog box. This allows features, such as mobile device synchronization, to be completed.

You receive the confirmation dialog box when a solution tries to programmatically access the GetRecipientFromID method.

Example

This Visual Basic for Applications (VBA) example gets the entry ID of the first recipient in the item in the Inbox folder with subject 'Test', obtains the recipient from the entry ID, and displays the recipient name. To run this example without any errors, make sure there is a mail item with subject 'Test' in the Inbox. The example may also fail if there are other types of items with subject 'Test' other than mail item in the Inbox.

Public Sub GetFromID()
    Dim nsp As Outlook.NameSpace
    Dim mpfInbox As Outlook.MAPIFolder
    Dim mail As Outlook.MailItem
    Dim rcp As Outlook.Recipient
    Dim rcp1 As Outlook.Recipient
    Dim strEntryId As String
    Set nsp = Application.GetNamespace("MAPI")
    Set mpfInbox = nsp.GetDefaultFolder(olFolderInbox)
    Set mail = mpfInbox.Items("Test")
    Set rcp = mail.Recipients.Item(1)
    strEntryId = rcp.EntryID
    Set rcp1 = nsp.GetRecipientFromID(strEntryId)
    MsgBox rcp1.Name
End Sub

Applies to | NameSpace Object