CreateFolderType Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The CreateFolderType class represents a request to create a folder.
public ref class CreateFolderType : ExchangeWebServices::BaseRequestType
public class CreateFolderType : ExchangeWebServices.BaseRequestType
Public Class CreateFolderType
Inherits BaseRequestType
- Inheritance
Examples
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 <span class="label">createFolder</span> = new CreateFolderType();
<span class="label">createFolder</span>.Folders = new BaseFolderType[] { folder1, folder2, folder3 };
<span class="label">createFolder</span>.ParentFolderId = targetID;
try
{
// Send the request and get the response.
CreateFolderResponseType response = esb.CreateFolder(<span class="label">createFolder</span>);
// 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);
}
}
Remarks
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.
Note: 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
Constructors
CreateFolderType() |
The CreateFolderType constructor initializes a new instance of the CreateFolderType class. |
Properties
Folders |
The Folders property gets or sets a set of folders to create in an Exchange database. This property gets or sets a set of FolderType, CalendarFolderType, ContactsFolderType, SearchFolderType, or TasksFolderType objects. This property is required. This is a read/write property. |
ParentFolderId |
The ParentFolderId property gets or sets the identifier of the folder that will contain the newly created folders. This property gets or sets a TargetFolderIdType, which can be a FolderIdType or DistinguishedFolderIdType object. This property is required. This is a read/write property. |