GetSharedDefaultFolder Method
Returns a MAPIFolder object that represents the specified default folder for the specified user. This method is used in a delegation scenario, where one user has delegated access to another user for one or more of their default folders (for example, their shared Calendar folder).
expression**.GetSharedDefaultFolder(Recipient**, FolderType)
*expression * Required. An expression that returns a NameSpace object.
Recipient Required Recipient object. The owner of the folder. The Recipient object must be resolved.
OlDefaultFolders
OlDefaultFolders can be one of these OlDefaultFolders constants. |
olFolderCalendar |
olFolderContacts |
olFolderDeletedItems |
olFolderDrafts |
olFolderInbox |
olFolderJournal |
olFolderJunk |
olFolderNotes |
olFolderOutbox |
olFolderSentMail |
olFolderTasks |
olPublicFoldersAllPublicFolders |
olFolderConflicts |
olFolderLocalFailures |
olFolderServerFailures |
olFolderSyncIssues |
Remarks
Microsoft Outlook does not allow you to open the following folders using the GetSharedDefaultFolder method. Therefore, the following constants cannot be used with this method:
- Deleted Items - olFolderDeletedItems
- OutBox - olFolderOutbox
- Sent Items - olFolderSentMail
- All Public Folders - olPublicFoldersAllPublicFolders
Example
This Visual Basic for Applications (VBA) example uses the GetSharedDefaultFolder method to resolve the Recipient object representing Dan Wilson, and then returns Dan's shared default Calendar folder.
Sub ResolveName()
Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myRecipient As Outlook.Recipient
Dim CalendarFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("Dan Wilson")
myRecipient.Resolve
If myRecipient.Resolved Then
Call ShowCalendar(myNamespace, myRecipient)
End If
End Sub
Sub ShowCalendar(myNamespace, myRecipient)
Dim CalendarFolder As Outlook.MAPIFolder
Set CalendarFolder = _
myNamespace.GetSharedDefaultFolder _
(myRecipient, olFolderCalendar)
CalendarFolder.Display
End Sub
If you use Microsoft Visual Basic Scripting Edition (VBScript) in an Outlook form, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript code.
Set myNameSpace = Application.GetNameSpace("MAPI")
Set myRecipient = myNameSpace.CreateRecipient("Dan Wilson")
myRecipient.Resolve
If myRecipient.Resolved Then
Set CalendarFolder = _
myNameSpace.GetSharedDefaultFolder _
(myRecipient, 9)
CalendarFolder.Display
End If
Applies to | NameSpace Object