CreateRecipient Method

Microsoft Outlook Visual Basic

CreateRecipient Method

       

Creates and returns a Recipient object. 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.

expression.CreateRecipient(RecipientName)

expression   Required. An expression that returns a NameSpace object.

RecipientName   Required String. The display name of the recipient.

Example

This Visual Basic for Applications example uses the CreateRecipient method to obtain the default Calendar folder for the user Eric Lang.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myRecipient = myNameSpace.CreateRecipient("Eric Lang")
Set hisCalendar = myNameSpace.GetSharedDefaultFolder _
    (myRecipient, olFolderCalendar)

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myRecipient = myNameSpace.CreateRecipient("Eric Lang")
Set hisCalendar = myNameSpace.GetSharedDefaultFolder _
    (myRecipient, 9)