SyncFolderItems Operation
Topic Last Modified: 2008-09-04
The SyncFolderItems operation synchronizes items between the Exchange server and the client.
Remarks
The SyncFolderItems operation will return a maximum of 512 changes. Subsequent SyncFolderItems requests must be performed to get additional changes. SyncFolderItems is similar to the FindItem operation in that it only returns a summary that describes the returned items. You can use the GetItem Operation to get the details of each item.
SyncFolderItems Request Example
Description
The following example of a SyncFolderItems request shows how to synchronize items in a folder. This example shows a folder item's synchronization that is not the first synchronization to have occurred for the Sent Items folder. The SyncState element is not included in the request for the first attempt to synchronize a client with the Exchange server. The first attempt to synchronize the items in a folder hierarchy will return all the items in the mailbox, excluding items that are identified in the Ignore element. This SyncFolderItems request will try to synchronize all changes to the folder items since the last synchronization. This request will ignore the attempt to synchronize the one item that is identified in the Ignore element.
Code
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<SyncFolderItems xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
<ItemShape>
<t:BaseShape>Default</t:BaseShape>
</ItemShape>
<SyncFolderId>
<t:DistinguishedFolderId Id="sentitems"/>
</SyncFolderId>
<SyncState>AEbJ94eMOAAA=</SyncState>
<Ignore>
<t:ItemId Id="AQApAHRAA==" ChangeKey="CQAAABY"/>
</Ignore>
<MaxChangesReturned>100</MaxChangesReturned>
</SyncFolderItems>
</soap:Body>
</soap:Envelope>
Comments
Request Elements
The following elements are used in the request:
Successful SyncFolderItems Response
Description
The following example shows a successful response to the SyncFolderItems request. In this example, a meeting request is synchronized from the Sent Items folder.
Code
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="https://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="628" MinorBuildNumber="0"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<SyncFolderItemsResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"
xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:SyncFolderItemsResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:SyncState>H4sIAAAAA=</m:SyncState>
<m:IncludesLastItemInRange>true</m:IncludesLastItemInRange>
<m:Changes>
<t:Create>
<t:MeetingRequest>
<t:ItemId Id="AQApAHRwA==" ChangeKey="CwAAABYA" />
<t:Subject>Budget Q3</t:Subject>
<t:Sensitivity>Normal</t:Sensitivity>
<t:IsOutOfDate>false</t:IsOutOfDate>
<t:HasBeenProcessed>true</t:HasBeenProcessed>
<t:ResponseType>NoResponseReceived</t:ResponseType>
<t:IntendedFreeBusyStatus>Busy</t:IntendedFreeBusyStatus>
<t:Start>2006-08-02T17:30:00Z</t:Start>
<t:End>2006-08-02T19:30:00Z</t:End>
<t:Location>Conference Room 2</t:Location>
<t:Organizer>
<t:Mailbox>
<t:Name>Dan Park</t:Name>
<t:EmailAddress>dpark@example.com</t:EmailAddress>
<t:RoutingType>SMTP</t:RoutingType>
</t:Mailbox>
</t:Organizer>
</t:MeetingRequest>
</t:Create>
</m:Changes>
</m:SyncFolderItemsResponseMessage>
</m:ResponseMessages>
</SyncFolderItemsResponse>
</soap:Body>
</soap:Envelope>
Comments
Successful Response Elements
The following elements are used in the response:
- ServerVersionInfo
- SyncFolderItemsResponse
- ResponseMessages
- SyncFolderItemsResponseMessage
- ResponseCode
- SyncState
- IncludesLastItemInRange
- Changes (Items)
- Create (ItemSync)
- MeetingRequest
- ItemId
- Subject
- Sensitivity
- IsOutOfDate
- HasBeenProcessed
- ResponseType
- IntendedFreeBusyStatus
- Start
- End
- Location
- Organizer
- Mailbox
- Name (EmailAddressType)
- EmailAddress
- RoutingType (EmailAddressType)
SyncFolderItems Error Response
Description
The following example shows an error response to a SyncFolderItems request. This error was caused by an invalid SyncState.
Code
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="https://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="628" MinorBuildNumber="0"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
</soap:Header>
<soap:Body>
<SyncFolderItemsResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"
xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
<m:ResponseMessages>
<m:SyncFolderItemsResponseMessage ResponseClass="Error">
<m:MessageText>Synchronization state data is corrupt or otherwise invalid.</m:MessageText>
<m:ResponseCode>ErrorInvalidSyncStateData</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:SyncState />
<m:IncludesLastItemInRange>true</m:IncludesLastItemInRange>
</m:SyncFolderItemsResponseMessage>
</m:ResponseMessages>
</SyncFolderItemsResponse>
</soap:Body>
</soap:Envelope>
Error Response Elements
The following elements are used in the error response: