CreateFolderType Class

The CreateFolderType class represents a request to create a folder.

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


<SerializableAttribute> _
<DebuggerStepThroughAttribute> _
<XmlTypeAttribute(Namespace:="")> _
<GeneratedCodeAttribute("wsdl", "2.0.50727.42")> _
<DesignerCategoryAttribute("code")> _
Public Class CreateFolderType
    Inherits BaseRequestType
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
public class CreateFolderType : BaseRequestType
[GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")] 
public ref class CreateFolderType : public BaseRequestType
/** @attribute SerializableAttribute() */ 
/** @attribute DebuggerStepThroughAttribute() */ 
/** @attribute XmlTypeAttribute(Namespace="") */ 
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */ 
/** @attribute DesignerCategoryAttribute("code") */ 
public class CreateFolderType extends BaseRequestType
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
public class CreateFolderType extends 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 (Exchange Web Services). For a sample that shows you how to implement managed folders, see Managed Folder Selector Sample.

Inheritance Hierarchy



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)

Thread Safety

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


Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003,

Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Longhorn, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional with Service Pack 2 (SP2)