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

为_AddressEntry_参数指定的联系人创建**ContactCard** 对象的实例。Creates an instance of a ContactCard object for the contact that is specified by the AddressEntry parameter.

语法Syntax

expressionexpression. CreateContactCard( _Address_ )

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

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
AddressEntryAddressEntry 必需Required AddressEntryAddressEntry 代表要为其创建联系人卡片的用户的**AddressEntry** 对象。The AddressEntry object that represents the user for whom the contact card is to be created.

返回值Return value

为指定用户创建的ContactCard对象。The Office.ContactCard object that is created for the specified user.

说明Remarks

Microsoft Office 类型库中提供了 ContactCard 对象。The ContactCard object is available in the type library of Microsoft Office. 在调用之前 CreateContactCard 在Microsoft Outlook中创建联系人卡片,Outlook 必须登录到 Outlook 会话中。Before calling CreateContactCard to create a contact card in Microsoft Outlook, Outlook must be logged into an Outlook session.

_AddressEntry_参数是一个AddressEntry对象, 该对象表示在**OlAddressEntryUserType** 枚举中定义的以下AddressEntry类型之一:The AddressEntry parameter is an AddressEntry object that represents one of the following AddressEntry types defined in the OlAddressEntryUserType enumeration:

  • olExchangeDistributionListAddressEntryolExchangeDistributionListAddressEntry

  • olExchangeRemoteUserAddressEntryolExchangeRemoteUserAddressEntry

  • olExchangeUserAddressEntryolExchangeUserAddressEntry

  • olOutlookContactAddressEntryolOutlookContactAddressEntry

  • olSmtpAddressEntryolSmtpAddressEntry

当您将以下任一OlAddressEntryUserType值作为参数传递给CreateContactCard方法时, Outlook 将引发 E_INVALIDARG 错误:Outlook raises the E_INVALIDARG error when you pass any of the following OlAddressEntryUserType values as an argument to the CreateContactCard method:

  • olExchangeAgentAddressEntryolExchangeAgentAddressEntry

  • olExchangeOrganizationAddressEntryolExchangeOrganizationAddressEntry

  • olExchangePublicFolderAddressEntryolExchangePublicFolderAddressEntry

  • olLdapAddressEntryolLdapAddressEntry

  • olOtherAddressEntryolOtherAddressEntry

  • olOutlookDistributionListAddressEntryolOutlookDistributionListAddressEntry

示例Example

下面的 Microsoft Visual Basic for Applications (VBA) 代码实例显示由 NameSpace 对象的 CurrentUser 属性定义的当前用户的联系人卡片。The following code sample in Microsoft Visual Basic for Applications (VBA) displays a Contact Card for the current user defined by the CurrentUser property of the NameSpace object.

不可直接从 VBA 窗口运行此代码。You cannot run this code directly from the VBA window. 若要运行代码, 请单击 "开发工具" 选项卡, 再单击 "" 菜单, 然后选择 "Project1" " DisplayContactCardForCurrentUser"。To run the code, click the Developer tab, click the Macros menu, and then select Project1.DisplayContactCardForCurrentUser. 有关 "开发工具" 选项卡的详细信息, 请参阅在 Outlook 中以开发人员模式运行For more information about the Developer tab, see Run in Developer Mode in Outlook.

Sub DisplayContactCardForCurrentUser() 
 
 Dim oCC As Office.ContactCard 
 
 Dim oAddrEntry As Outlook.AddressEntry 
 
 Set oAddrEntry = Application.session.CurrentUser.AddressEntry 
 
 Set oCC = Application.session.CreateContactCard(oAddrEntry) 
 
 oCC.Show msoContactCardFull, 100, 100, 100, 100, 100, True 
 
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.