How to: Add a Folder to the Folder List

This example shows how to use the Add(String, Object) method to add a folder to the Outlook folder list.

Programming Applications for Office Outlook 2007

The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007, from Microsoft Press (ISBN 9780735622494, copyright Microsoft Press 2007, all rights reserved).

Buy this book

Sample chapters

In the following code example, AddMyNewFolder calls the Add method of the Folders collection to add a Folder object that represents a folder called “My New Folder” to the Inbox in the Outlook folder list. “My New Folder” is then displayed.

If you use Microsoft Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 14.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.

using Outlook = Microsoft.Office.Interop.Outlook;
private void AddMyNewFolder()
    Outlook.Folder folder =
        as Outlook.Folder;
    Outlook.Folders folders = folder.Folders;
        Outlook.Folder newFolder = folders.Add(
            "My New Folder", Type.Missing)
            as Outlook.Folder;
            "Could not add 'My New Folder'",
            "Add Folder",

Other Resources