CreateFolderType Class
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

CreateFolderType Class

The CreateFolderType class represents a request to create a folder.

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

[SerializableAttribute] 
[DebuggerStepThroughAttribute] 
[XmlTypeAttribute(Namespace="http://schemas.microsoft.com/exchange/services/2006/messages")] 
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
[DesignerCategoryAttribute("code")] 
public class CreateFolderType : BaseRequestType
/** @attribute SerializableAttribute() */ 
/** @attribute DebuggerStepThroughAttribute() */ 
/** @attribute XmlTypeAttribute(Namespace="http://schemas.microsoft.com/exchange/services/2006/messages") */ 
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */ 
/** @attribute DesignerCategoryAttribute("code") */ 
public class CreateFolderType extends BaseRequestType
SerializableAttribute 
DebuggerStepThroughAttribute 
XmlTypeAttribute(Namespace="http://schemas.microsoft.com/exchange/services/2006/messages") 
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
DesignerCategoryAttribute("code") 
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.

Bb426279.note(en-us,EXCHG.80).gifNote:
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.

System.Object
   ExchangeWebServices.BaseRequestType
    ExchangeWebServices.CreateFolderType

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;

    try
    {
        // 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.
                }

                else
                {
                    //TODO: Handle the SearchFolderType, ContactsFolderType, and FolderType folders.
                }
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

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)
Show:
© 2016 Microsoft