NameSpace.GetDefaultFolder method (Outlook)
Returns a Folder object that represents the default folder of the requested type for the current profile; for example, obtains the default Calendar folder for the user who is currently logged on.
Syntax
expression. GetDefaultFolder
( _FolderType_
)
expression A variable that represents a NameSpace object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
FolderType | Required | OlDefaultFolders | The type of default folder to return. |
Return value
A Folder object that represents the default folder of the requested type for the current profile.
Remarks
To return a specific non-default folder, use the Folders collection.
If the default folder of the requested type does not exist, depending on the type, Outlook may create and return the folder, or may raise an error. For example, if olFolderManagedEmail is specified as the FolderType but the Managed Folders group has not been deployed, Microsoft Outlook raises an error.
Example
This Visual Basic for Applications (VBA) example uses the CurrentFolder property to change the displayed folder to the user's default Calendar folder.
Sub ChangeCurrentFolder()
Dim myNamespace As Outlook.NameSpace
Set myNamespace = Application.GetNamespace("MAPI")
Set Application.ActiveExplorer.CurrentFolder = _
myNamespace.GetDefaultFolder(olFolderCalendar)
End Sub
This VBA example returns the first folder in the Tasks Folders collection.
Sub DisplayATaskFolder()
Dim myNamespace As Outlook.NameSpace
Dim myTasks As Outlook.Folder
Dim myFolder As Outlook.Folder
Set myNamespace = Application.GetNamespace("MAPI")
Set myTasks = myNamespace.GetDefaultFolder(olFolderTasks)
Set myFolder = myTasks.Folders(1)
myFolder.Display
End Sub
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기