This documentation is archived and is not being maintained.

How to: Create Custom Folder Items

Note Required applications

The code example in this topic can be compiled only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005


    Visual Studio Team System

  • Microsoft Office Outlook 2003


This code does not compile if you use the VSTO 2005 SE version of the Outlook 2003 add-in project template. For more information, see Getting Started Programming Application-Level Add-ins.

This example creates a new folder in Microsoft Office Outlook 2003. The name of the user who is logged on is used for the folder name.


private void CreateCustomFolder()
    Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
    string userName = (string)this.ActiveExplorer()
    Outlook.MAPIFolder customFolder = null;
        customFolder = (Outlook.MAPIFolder)inBox.Folders.Add(userName,
        MessageBox.Show("You have created a new folder named " +
            userName + ".");
    catch (Exception ex)
        MessageBox.Show("The following error occurred: " + ex.Message);

See Also