共用方式為


NameSpace.GetRecipientFromID 方法 (Outlook)

若有效) ,則回傳由指定條目 ID 識別的 Recipient 物件 (。

語法

expressionGetRecipientFromID( _EntryID_ )

一個代表「NameSpace」物件的變數。

參數

名稱 必要/選用 資料類型 描述
EntryID 必要 字串 收件人的 EntryID

傳回值

代表指定之收件者的 Recipient 物件。

註解

此方法用於簡化 MAPI 與 OLE/訊息應用程式及 Microsoft Outlook 之間的轉換。

此方法類似於帳戶物件的 GetRecipientFromID 方法。 如果在目前的設定檔中有多個 Microsoft Exchange 帳戶,請使用對應帳戶的 GetRecipientFromID 方法。

範例

這個 Visual Basic for Applications (VBA) 範例會取得收件匣資料夾 Items 集合中第一個項目的第一個收件人的條目 ID,使用 GetRecipientFromID 從條目 ID 取得收件人,並顯示收件人名稱。

Public Sub GetRecipientFromID() 
 
 Dim inbox As Outlook.folder 
 
 Dim mail As Outlook.MailItem 
 
 Dim rcp As Outlook.Recipient 
 
 Dim rcp1 As Outlook.Recipient 
 
 Dim strEntryId As String 
 
 
 
 'Get Inbox folder. 
 
 Set inbox = Application.session.GetDefaultFolder(olFolderInbox) 
 
 
 
 ' Get the first item in the Inbox. 
 
 Set mail = inbox.items(1) 
 
 
 
 ' Get the first recipient on that first item. 
 
 Set rcp = mail.Recipients.Item(1) 
 
 
 
 ' Get the string entry ID of the recipient. 
 
 strEntryId = rcp.entryID 
 
 
 
 ' Get the Recipient object based on the string entry ID. 
 
 Set rcp1 = Application.session.GetRecipientFromID(strEntryId) 
 
 
 
 MsgBox "Recipient Name: " & rcp1.name, vbInformation 
 
End Sub

另請參閱

命名空間物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應