Edit

Share via


MoveItemType Class

Definition

The MoveItemType class represents an operation to move items in a mailbox.

public ref class MoveItemType : ExchangeWebServices::BaseMoveCopyItemType
public class MoveItemType : ExchangeWebServices.BaseMoveCopyItemType
Public Class MoveItemType
Inherits BaseMoveCopyItemType
Inheritance

Examples

The following example shows how to move two items to the Deleted Items default folder.

static void MoveItem(ExchangeServiceBinding esb)
{ 
    // Identify the items to move.
    ItemIdType item1 = new ItemIdType();
    ItemIdType item2 = new ItemIdType();
    item1.Id = "AAAlAE1";
    item2.Id = "AAAlAE2";
    ItemIdType[] items = new ItemIdType[2] { item1, item2 };

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

    // Form the move request.
    MoveItemType <span class="label">request</span> = new MoveItemType();
<span class="label">request</span>.ItemIds = items;
<span class="label">request</span>.ToFolderId = new TargetFolderIdType();
<span class="label">request</span>.ToFolderId.Item = destFolder;

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

        foreach (ResponseMessageType rmt in rmta)
        {
            if (rmt.ResponseClass == ResponseClassType.Error)
            {
                throw new Exception("Item move failed.");
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

Remarks

The item identifier of the new item is returned in the response message (MoveItemResponseType). An item identifier is not returned in a response for a cross-mailbox or mailbox to public folder MoveItem operation.

Constructors

MoveItemType()

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

Properties

ItemIds

The ItemIds property gets or sets an array of elements of type BaseItemIdType that specifies a set of items to move or copy.

(Inherited from BaseMoveCopyItemType)
ReturnNewItemIds (Inherited from BaseMoveCopyItemType)
ReturnNewItemIdsSpecified (Inherited from BaseMoveCopyItemType)
ToFolderId

The ToFolderId property gets or sets an instance of the TargetFolderIdType class that specifies the folder to which to move or copy the items specified by the ItemIds property.

(Inherited from BaseMoveCopyItemType)

Applies to