傳回由指定項目識別碼所識別的 收件者 物件 (如果有效) 。
語法
expression。
GetRecipientFromID( _EntryID_ )
運算式 代表 'NameSpace' 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| EntryID | 必要 | 字串 | 收件者的 EntryID 。 |
傳回值
代表指定之收件者的 Recipient 物件。
註解
此方法可用來簡化 MAPI 與 OLE/訊息應用程式和 Microsoft Outlook 之間的轉換。
這個方法類似於 Account 物件的 GetRecipientFromID 方法。 如果在目前的設定檔中有多個 Microsoft Exchange 帳戶,請使用對應帳戶的 GetRecipientFromID 方法。
範例
此 Visual Basic for Applications (VBA) 範例會針對 Inbox 資料夾的 [項目] 集合中第一個項目取得第一個收件者的項目識別碼、使用 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
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。