0

我正在尝试构建一个 ActiveSync 客户端应用程序。我有一个测试 Hotmail 帐户,其中包含过去 6 个月的邮件,其中大部分未读。Hotmail 使用 ActiveSync v2.5。我尝试了同步命令,但我只能收到新邮件,旧(> 3 个月)邮件不会出现!

我错过了什么还是它是这样工作的?

[编辑:包括请求和响应 Xml 以使其更清晰]

初始请求:

<?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>

回复:

<?xml version="1.0" encoding="UTF-8" ?>
<Sync xmlns="AirSync">
    <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>

要求:

<?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>

回复:

<?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>

此外,相同的代码适用于 GMail 帐户(使用 ActiveSync v12.0)

4

2 回答 2

1

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!

于 2011-10-13T06:03:20.730 回答
0

确保您没有传递FilterType会限制返回对象范围的元素。

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]

于 2011-10-12T11:59:12.163 回答