MoveItemType class
The Exchange Web Services (EWS) autogenerated proxy object models that are created by .NET Framework proxy generators are deemphasized and we do not recommend that you use them for new .NET Framework client development. We recommend that you use the EWS Managed API to develop clients that target the .NET Framework. We recommend that you use the EWS Java API to develop clients that target the Java platform. For more information about the EWS Managed API, see Explore the EWS Managed API.
The MoveItemType class represents an operation to move items in a mailbox.
ExchangeWebServices.BaseRequestType
ExchangeWebServices.BaseMoveCopyItemType
ExchangeWebServices.MoveItemType
Assembly: EWS (in EWS.dll)
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.
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 request = new MoveItemType(); request.ItemIds = items; request.ToFolderId = new TargetFolderIdType(); request.ToFolderId.Item = destFolder; try { // Send the request and get the response. MoveItemResponseType response = esb.MoveItem(request); 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); } }