GetDefaultFolder Method Example
This Visual Basic for Applications example uses the GetDefaultFolder method to obtain the default Calendar folder for the current user.
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myCalendar = myNameSpace.GetDefaultFolder(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 myCalendar = myNameSpace.GetDefaultFolder(9)
This Visual Basic for Applications example returns the first folder in the Tasks Folders collection.
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myTasks = myNameSpace.GetDefaultFolder(olFolderTasks)
Set myFolder = myTasks.Folders(1)