I'm trying to build a ActiveSync client application. I have a test Hotmail account, which has mails from the past 6 months, most of them unread. Hotmail uses ActiveSync v2.5. I tried the Sync command, but I'm able to get only new mails, the old (> 3 months) mails don't appear!
Am I missing something or is this how it works?
[Edit: Including the request and response Xml to make it more clearer]
Initial Request:
<?xml version="1.0" ?>
<Sync xmlns="AirSync:">
<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>0</SyncKey>
<CollectionId>00000000-0000-0000-0000-000000000001</CollectionId>
<WindowSize>512</WindowSize>
</Collection>
</Collections>
</Sync>
Response:
<?xml version="1.0" encoding="UTF-8" ?>
<Sync xmlns="AirSync">
开发者_JAVA技巧<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>000000000{813672f0-cc63-4308-9a33-4e8c1d0f351e}0</SyncKey>
<CollectionId>00000000-0000-0000-0000-000000000001</CollectionId>
<Status>1</Status>
</Collection>
</Collections>
</Sync>
Request:
<?xml version="1.0" ?>
<Sync xmlns="AirSync:">
<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>000000000{813672f0-cc63-4308-9a33-4e8c1d0f351e}0</SyncKey>
<CollectionId>00000000-0000-0000-0000-000000000001</CollectionId>
<GetChanges />
<WindowSize>512</WindowSize>
</Collection>
</Collections>
</Sync>
Response:
<?xml version="1.0" encoding="UTF-8" ?>
<Sync xmlns="AirSync">
<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>000000000{13704907-A726-4149-8186-E3EEE98D9918}1</SyncKey>
<CollectionId>00000000-0000-0000-0000-000000000001</CollectionId>
<Status>1</Status>
<Commands>
<Add>[Contains email details]</Add>
</Commands>
</Collection>
</Collections>
</Sync>
Also, the same code works great for a GMail account (which uses ActiveSync v12.0)
Apparently, the Hotmail servers respond differently to different devices. I modified the User-Agent value sent to the server to Apple-iPhone/705.18 and it started working!
Make sure you're not passing a FilterType
element which would restrict the range of objects returned.
Secondly, watch for a MoreAvailable
element in the Sync response which would indicate that you haven't yet received all the objects from the server.
[Edited based on comments]
精彩评论