CreateRecipient Method 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)