Folder.Folders Property (Outlook)

Returns the Folders collection that represents all the folders contained in the specified Folder. Read-only.

Version Information

Version Added: Outlook 2007

Syntax

expression .Folders

expression A variable that represents a Folder object.

Remarks

The NameSpace object is the root of all the folders for the given name space.

Example

This Visual Basic for Applications (VBA) example uses the Folders.Add method to add the new folder named "My Personal Contacts" to the default Contacts folder.

Sub CreatePersonalContacts() 
 
 Dim myNamespace As Outlook.NameSpace 
 
 Dim myFolder As Outlook.Folder 
 
 Dim myNewFolder As Outlook.Folder 
 
 
 
 Set myNamespace = Application.GetNamespace("MAPI") 
 
 Set myFolder = myNamespace.GetDefaultFolder(olFolderContacts) 
 
 Set myNewFolder = myFolder.Folders.Add("My Personal Contacts") 
 
End Sub

This VBA example uses the Folders.Add method to add two new folders in the Tasks folder. The first folder, "My Notes Folder", will contain note items. The second folder, "My Contacts Folder", will contain contact items. If the folders already exist, a message box will inform the user.

Sub CreateFolders() 
 
 Dim myNamespace As Outlook.NameSpace 
 
 Dim myFolder As Outlook.Folder 
 
 Dim myNotesFolder As Outlook.Folder 
 
 Dim myContactFolder As Outlook.Folder 
 
 
 
 Set myNamespace = Application.GetNamespace("MAPI") 
 
 Set myFolder = myNamespace.GetDefaultFolder(olFolderTasks) 
 
 On Error GoTo ErrorHandler 
 
 Set myNotesFolder = _ 
 
 myFolder.Folders.Add("My Notes Folder", olFolderNotes) 
 
 Set myContactFolder = _ 
 
 myFolder.Folders.Add("My Contacts Folder", olFolderContacts) 
 
 Exit Sub 
 
ErrorHandler: 
 
 MsgBox "Error creating the folder. The folder may already exist." 
 
 Resume Next 
 
End Sub

See Also

Concepts

Folder Object Members

Folder Object