Export (0) Print
Expand All

MoveFolderType Class

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

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

'Declaration
<SerializableAttribute> _
Public Class MoveFolderType _
	Inherits BaseMoveCopyFolderType
'Usage
Dim instance As MoveFolderType

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;

    try
    {
        // 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)
    {
        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.
Show:
© 2014 Microsoft