Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Folders.Add Method

Office 2007
Creates a new folder in the Folders collection.

Syntax

expression.Add(Name, Type)

expression   A variable that represents a Folders object.

Parameters

NameRequired/OptionalData TypeDescription
NameRequiredStringThe display name for the new folder.
TypeOptionalLongThe Outlook folder type for the new folder. If the folder type is not specified, the new folder will default to the same type as the folder in which it is created. Can be one of the following OlDefaultFolders constants: olFolderCalendar, olFolderContacts, olFolderDrafts, olFolderInbox, olFolderJournal, olFolderNotes, or olFolderTasks. The constants olFolderConflicts, olFolderDeletedItems, olFolderJunk, olFolderLocalFailures, olFolderManagedEmail, olFolderOutbox, olFolderRssSubscriptions, olFolderSentMail, olFolderServerFailures, olFolderSyncIssues, olFolderToDo, and olPublicFoldersAllPublicFolders cannot be specified for this argument.

Return Value
A Folder object that represents the new folder.

Example

This VBA example uses the Add method to add the new folder named "My Contacts" to the current (default) Contacts folder.

Visual Basic for Applications
Sub AddContactsFolder()
    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 Contacts")
End Sub

This VBA example uses the Add method to add three new folders in the Tasks folder. The first folder, "Notes Folder", will contain note items. The second folder, "Contacts Folder", will contain contact items. The third folder, “Public Folder” will be a public folder. If the folders already exist, a message box will inform the user.

Visual Basic for Applications
Sub AddFolders()
    Dim myNameSpace As Outlook.NameSpace
    Dim myFolder As Outlook.Folder
    Dim myNotesFolder As Outlook.Folder
    Dim myContactsFolder As Outlook.Folder
    Dim myPublicFolder As Outlook.Folder
 
    Set myNameSpace = Application.GetNamespace("MAPI")
    Set myFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
    On Error GoTo ErrorHandler
    Set myNotesFolder = myFolder.Folders.Add("Notes Folder", olFolderNotes)
    Set myContactsFolder = myFolder.Folders.Add("Contacts Folder", olFolderContacts)
    Set myPublicFolder = myFolder.Folders.Add("Public Folder", olPublicFoldersAllPublicFolders)
    Exit Sub
ErrorHandler:
    MsgBox "This folder already exists!"
    Resume Next
End Sub



Community Additions

Show: