GetSharedDefaultFolder Method Example

This Visual Basic for Applications example uses the GetSharedDefaultFolder method to resolve the Recipient object representing Kim Buhler, and then returns her shared default Calendar folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myRecipient = myNameSpace.CreateRecipient("Kim Buhler")
myRecipient.Resolve
If myRecipient.Resolved Then
    Set KimCalendarFolder = _
        myNameSpace.GetSharedDefaultFolder _
        (myRecipient, olFolderCalendar)
End If

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("Kim Buhler")
myRecipient.Resolve
If myRecipient.Resolved Then
    Set KimCalendarFolder = _
        myNameSpace.GetSharedDefaultFolder _
        (myRecipient, 9)
End If