NameSpace.CreateContactCard Method (Outlook)
Creates an instance of a ContactCard object for the contact that is specified by the AddressEntry parameter.
Version Information
Version Added: Outlook 2010
Syntax
expression .CreateContactCard(Address)
expression A variable that represents a NameSpace object.
Parameters
Name |
Required/Optional |
Data Type |
Description |
---|---|---|---|
AddressEntry |
Required |
AddressEntry |
The AddressEntry object that represents the user for whom the contact card is to be created. |
Return Value
The Office.ContactCard object that is created for the specified user.
Remarks
The ContactCard object is available in the type library of Microsoft Office. Before calling CreateContactCard to create a contact card in Microsoft Outlook, Outlook must be logged into an Outlook session.
The AddressEntry parameter is an AddressEntry object that represents one of the following AddressEntry types defined in the OlAddressEntryUserType enumeration:
olExchangeDistributionListAddressEntry
olExchangeRemoteUserAddressEntry
olExchangeUserAddressEntry
olOutlookContactAddressEntry
olSmtpAddressEntry
Outlook raises the E_INVALIDARG error when you pass any of the following OlAddressEntryUserType values as an argument to the CreateContactCard method:
olExchangeAgentAddressEntry
olExchangeOrganizationAddressEntry
olExchangePublicFolderAddressEntry
olLdapAddressEntry
olOtherAddressEntry
olOutlookDistributionListAddressEntry
Example
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.
You cannot run this code directly from the VBA window. To run the code, click the Developer tab, click the Macros menu, and then select Project1.DisplayContactCardForCurrentUser. 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