命名空间 CreateRecipient 方法 (Outlook)NameSpace.CreateRecipient method (Outlook)

创建**收件人** 对象。Creates a Recipient object.

语法Syntax

expressionexpression. CreateRecipient( _RecipientName_ )

_表达式_一个代表NameSpace对象的变量。expression A variable that represents a NameSpace object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
RecipientNameRecipientName 必需Required StringString 收件人的姓名;它可以是一个表示收件人的显示名称、别名或完整 SMTP 电子邮件地址的字符串。The name of the recipient; it can be a string representing the display name, the alias, or the full SMTP email address of the recipient.

返回值Return value

一个代表新收件人的收件人对象。A Recipient object that represents the new recipient.

说明Remarks

此方法最常用于创建使用 GetSharedDefaultFolder 方法时,使用的 收件人 对象,例如,以打开代理者的文件夹。This method is most commonly used to create a Recipient object for use with the GetSharedDefaultFolder method, for example, to open a delegator's folder. 它还可以用于验证给定的名称对照通讯簿。It can also be used to verify a given name against an address book.

示例Example

本 Visual Basic for Applications (VBA) 示例使用**GetSharedDefaultFolder** 方法来解析表示 dan Wilson 的**收件人** 对象, 然后返回 dan 的共享的默认 "日历" 文件夹。This Visual Basic for Applications (VBA) example uses the GetSharedDefaultFolder method to resolve the Recipient object representing Dan Wilson, and then returns Dan's shared default Calendar folder. 若要运行此示例,使用有效的收件人姓名替换 Dan Wilson,并确保日历已共享且您有查看该日历的权限。To run this example, replace 'Dan Wilson' with a valid recipient name and make sure the calendar is shared and you have permissions to view the calendar.

Sub ResolveName() 
 
 Dim myNamespace As Outlook.NameSpace 
 
 Dim myRecipient As Outlook.Recipient 
 
 Dim CalendarFolder As Outlook.Folder 
 
 
 
 Set myNamespace = Application.GetNamespace("MAPI") 
 
 Set myRecipient = myNamespace.CreateRecipient("Dan Wilson") 
 
 myRecipient.Resolve 
 
 If myRecipient.Resolved Then 
 
 Call ShowCalendar(myNamespace, myRecipient) 
 
 End If 
 
End Sub 
 
 
 
Sub ShowCalendar(myNamespace, myRecipient) 
 
 Dim CalendarFolder As Folder 
 
 
 
 Set CalendarFolder = _ 
 
 myNamespace.GetSharedDefaultFolder _ 
 
 (myRecipient, olFolderCalendar) 
 
 CalendarFolder.Display 
 
End Sub

另请参阅See also

命名空间对象NameSpace Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.