Share via


Outlook) (NameSpace.GetRecipientFromID 方法

如果有效) ,會傳回由指定專案識別碼所識別 (的 Recipient 物件。

語法

expressionGetRecipientFromID( _EntryID_ )

表達 代表 'NameSpace' 物件的變數。

參數

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

傳回值

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

註解

這個方法可用來簡化 MAPI 與 OLE/Messaging 應用程式與 Microsoft Outlook 之間的轉換。

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

範例

這個 Visual Basic for Applications (VBA) 範例會取得 [件匣] 資料夾之Items集合中第一個專案的第一個收件者專案識別碼、使用GetRecipientFromID從專案識別碼取得收件者,並顯示收件者名稱。

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

另請參閱

NameSpace 物件

支援和意見反應

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