CreateFolderType class

The CreateFolderType class represents a request to create a folder.


Namespace:  ExchangeWebServices
Assembly:  EWS (in EWS.dll)

public class CreateFolderType : BaseRequestType

The CreateFolderType class is used to create tasks folders, search folders, contacts folders, calendar folders, and regular folders. New folders can be extended by using the ExtendedProperty property.


The CreateFolderType class does not add managed folders to a mailbox. For information about how to add managed folders to a mailbox, see CreateManagedFolderRequestType, CreateManagedFolder operation, and Adding Managed Folders. For a sample that shows you how to implement managed folders, see Managed Folder Selector Sample.

The following example shows you how to create a set of folders in the Inbox. The example creates a regular folder, a contacts folder, and a tasks folder.

static void CreateFolder(ExchangeServiceBinding esb)
    // Identify the folders to create.
    FolderType folder1 = new FolderType();
    ContactsFolderType folder2 = new ContactsFolderType();
    TasksFolderType folder3 = new TasksFolderType();
    folder1.DisplayName = "MyNewRegularFolder";
    folder2.DisplayName = "MyNewContactsFolder";
    folder3.DisplayName = "MyNewTasksFolder";

    // Identify where the new folders are created.
    DistinguishedFolderIdType distFolder = new DistinguishedFolderIdType();
    distFolder.Id = DistinguishedFolderIdNameType.inbox;
    TargetFolderIdType targetID = new TargetFolderIdType();
    targetID.Item = distFolder;

    // Create the request.
    CreateFolderType createFolder = new CreateFolderType();
    createFolder.Folders = new BaseFolderType[] { folder1, folder2, folder3 };
    createFolder.ParentFolderId = targetID;

        // Send the request and get the response.
        CreateFolderResponseType response = esb.CreateFolder(createFolder);

        // Get the response messages.
        ResponseMessageType[] rmta = response.ResponseMessages.Items;

        foreach (ResponseMessageType responseMessage in rmta)
            // Perform error checks in production code.
            FolderInfoResponseMessageType firmt = (responseMessage as FolderInfoResponseMessageType);
            BaseFolderType[] folders = firmt.Folders;

            foreach (BaseFolderType folder in folders)
                if (folder is TasksFolderType)
                    TasksFolderType tft = (folder as TasksFolderType);
                    //TODO: Handle the task folder.

                else if (folder is CalendarFolderType)
                    CalendarFolderType cft = (folder as CalendarFolderType);
                    // TODO: Handle the calendar folder.

                    //TODO: Handle the SearchFolderType, ContactsFolderType, and FolderType folders.
    catch (Exception e)

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.