MoveFolder operation
The MoveFolder operation moves folders from a specified folder and puts them in another folder.
The MoveFolder operation is similar to the CopyFolder operation. You cannot move distinguished folders. You can move multiple folders at one time to the destination folder.
The following example of a MoveFolder request shows how to form a request to move a folder identified by the FolderId and put the folder in the Junk E-mail distinguished folder.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<MoveFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<ToFolderId>
<t:DistinguishedFolderId Id="junkemail"/>
</ToFolderId>
<FolderIds>
<t:FolderId Id="AScAc"/>
</FolderIds>
</MoveFolder>
</soap:Body>
</soap:Envelope>
Бележка
The value of the ID attribute of the FolderId element has been shortened for readability.
This MoveFolder request includes the following elements:
See the schema for additional elements that you can use to form a MoveFolder request.
Бележка
The default location of the schema is in the EWS virtual directory on the computer that has the Client Access server role installed.
The following example shows a successful response to the MoveFolder request.
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="685" MinorBuildNumber="8"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<MoveFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:MoveFolderResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:Folders>
<t:Folder>
<t:FolderId Id="AAAlAFV" ChangeKey="AQAAAB" />
</t:Folder>
</m:Folders>
</m:MoveFolderResponseMessage>
</m:ResponseMessages>
</MoveFolderResponse>
</soap:Body>
</soap:Envelope>
Бележка
The folder ID and the change key have been shortened to preserve readability.
The FolderId that is returned in the response represents the folder that was moved to the new the folder location.
The MoveFolder response includes the following elements:
The following example shows an error response that occurs when you try to move a distinguished folder.
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="685" MinorBuildNumber="8"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<MoveFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:MoveFolderResponseMessage ResponseClass="Error">
<m:MessageText>Cannot move distinguished folder.</m:MessageText>
<m:ResponseCode>ErrorMoveDistinguishedFolder</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Folders />
</m:MoveFolderResponseMessage>
</m:ResponseMessages>
</MoveFolderResponse>
</soap:Body>
</soap:Envelope>
The MoveFolder error response includes the following elements: