CopyFolderType Class

Definition

The CopyFolderType class represents an operation to copy folders in an Exchange database.

public ref class CopyFolderType : ExchangeWebServices::BaseMoveCopyFolderType
public class CopyFolderType : ExchangeWebServices.BaseMoveCopyFolderType
Public Class CopyFolderType
Inherits BaseMoveCopyFolderType
Inheritance

Examples

The following code example shows you how to copy two folders to a destination folder and then get the new folder identifiers.

static void CopyFolder(ExchangeServiceBinding esb)
{
    // Identify the folders to copy.
    FolderIdType folder1 = new FolderIdType();
    FolderIdType folder2 = new FolderIdType();
    folder1.Id = "AQAlAE1BQG1haW5";
    folder2.Id = "AQAlAE1BQG1haW4";
    FolderIdType[] folders = new FolderIdType[2] { folder1, folder2 };

    // Identify the destination folder.
    FolderIdType destFolder = new FolderIdType();
    destFolder.Id = "AQAlAE1BQG1haW1";

    // Form the copy folder request.
    CopyFolderType <span class="label">request</span> = new CopyFolderType();
<span class="label">request</span>.FolderIds = folders;
<span class="label">request</span>.ToFolderId = new TargetFolderIdType();
<span class="label">request</span>.ToFolderId.Item = destFolder;

    try
    {
        // Send the request and get the response.
        CopyFolderResponseType response = esb.CopyFolder(<span class="label">request</span>);
        ArrayOfResponseMessagesType aormt = response.ResponseMessages;
        ResponseMessageType[] rmta = aormt.Items;

        foreach (ResponseMessageType rmt in rmta)
        {
            if (rmt.ResponseClass == ResponseClassType.Success)
            { 
                foreach (BaseFolderType folder in (rmt as FolderInfoResponseMessageType).Folders)
                {
                    // Get the new folder ID and change key.
                    FolderIdType identifier = folder.FolderId;
                }
            }
            else
            {
                throw new Exception("Folder copy failed.");
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

Remarks

The CopyFolder operation copies folders and all their contents while the content is maintained in the same structure. The copied folders will have new folder identifiers and change keys.

Constructors

CopyFolderType()

The CopyFolderType constructor initializes a new instance of the CopyFolderType class.

Properties

FolderIds

The FolderIds property gets or sets an array of folders to move or copy to the folder that is identified by the ToFolderId property.

(Inherited from BaseMoveCopyFolderType)
ToFolderId

The ToFolderId property gets or sets the destination folder for a moved or copied folder.

(Inherited from BaseMoveCopyFolderType)

Applies to