MoveFolderType class
Collapse the table of content
Expand the table of content

MoveFolderType class

The MoveFolderType class represents an operation to move folders in a mailbox.

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

public class MoveFolderType : BaseMoveCopyFolderType

The folder identifier and change key do not change when you move a folder. You cannot move default folders.

The following example shows you how to move two folders to another folder.

static void MoveFolder(ExchangeServiceBinding esb)
    // Identify the folders to move.
    FolderIdType folder1 = new FolderIdType();
    FolderIdType folder2 = new FolderIdType();
    folder1.Id = "AQAlAE1BQG1";
    folder2.Id = "AQAlAE1BQG3";
    FolderIdType[] folders = new FolderIdType[2] { folder1, folder2 };

    // Identify the destination folder.
    DistinguishedFolderIdType destFolder = new DistinguishedFolderIdType();
    destFolder.Id = DistinguishedFolderIdNameType.drafts;

    // Form the move folder request.
    MoveFolderType request = new MoveFolderType();
    request.FolderIds = folders;
    request.ToFolderId = new TargetFolderIdType();
    request.ToFolderId.Item = destFolder;

        // Send the request and get the response.
        MoveFolderResponseType response = esb.MoveFolder(request);
        ArrayOfResponseMessagesType aormt = response.ResponseMessages;
        ResponseMessageType[] rmta = aormt.Items;

        foreach (ResponseMessageType rmt in rmta)
            if (rmt.ResponseClass == ResponseClassType.Error)
                throw new Exception("Folder move failed.");

    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.
© 2015 Microsoft