【问题标题】:correlating messages through moves via EWS通过 EWS 通过移动关联消息
【发布时间】:2021-06-11 18:48:11
【问题描述】:

假设您正在构建一个从 EWS 同步消息正文和元数据的应用程序。让您的初始状态同步非常简单:致电 SyncFolderHierarchy to get the folder list, SyncFolderItems to get the message ItemIds, and GetItem to get the message bodies and metadata.

当试图通过移动跟踪消息时,事情变得有点复杂。移动后,对SyncFolderItems 的调用将在一个文件夹中返回创建,在另一个文件夹中返回删除。您希望将这些关联起来,以便客户端可以避免重新下载邮件正文和附件。 (另外,这样客户端就不会丢失与其本地副本关联的任何元数据。)但是,在文件夹之间移动消息会更改其 EWS ItemId,因此 ItemId 不能用于关联创建和删除。

EWS 文档建议 subscribing to streaming notifications,它确实支持移动事件。但是流式通知aren't buffered when the stream is not connected,因此在建立流式连接之前,您仍然必须使客户端恢复同步。因此,流式通知不能成为完整的关联移动解决方案。

另一个 EWS 选项是 subscribing to pull notifications。与流式通知一样,拉取通知也支持移动事件。与流式通知不同,拉订阅缓冲更改。但是,如果您的客户端在拉取订阅到期时处于脱机状态,那么您又会回到同样的情况。 (不过,由于a pull subscription can be scoped to last a full day,这可能仍然可行。)

最后一个选项是使用 ItemId 以外的东西来关联通过 SyncFolderItems 移动的项目:

A MAPI store provider assigns a unique ID string when an item is created in its store. Therefore, the EntryID property is not set for a Microsoft Outlook item until it is saved or sent. The EntryID changes when an item is moved into another store, for example, from your Inbox to a Microsoft Exchange Server public folder, or from one Personal Folders (.pst) file to another .pst file. Solutions should not depend on the EntryID property to be unique unless items will not be moved. The EntryID property returns a MAPI long-term EntryID.

那么...通过 EWS 通过移动关联项目的正确方法是什么?

【问题讨论】:

    标签: office365 exchangewebservices


    【解决方案1】:

    有两件事可以帮助你:

    第一种方法

    我们通过为每个项目(在我们的案例中为日历项目)提供一个 用户定义的属性(也称为 扩展属性)来解决这个问题,其中包含 EWS 项目 ID 的副本(无论何时我们编写/更新它)。

    每当我们读取要同步的项目时,我们都会检查该属性是否仍与 EWS 项目 ID 匹配。如果没有,我们知道该项目已被移动并相应地处理它(并且我们清除用户定义的属性)。

    与其他一些用于记账的用户定义属性一起,这使我们能够维护 Exchange 中的项目与我们的应用程序中的项目之间的完整性。

    第二种方法

    在某些极端情况下这不起作用(但我们忽略了它们)。对于那些,使用 EWS 项目 ID 进行跟踪不再有效,建议使用 UID/PidLidGlobalObject 属性。我不必实际实现这一点,但这里有一些参考资料可以帮助您入门:

    "Exchange calendar: Is ConversationId a good identifier of master events for FindItem occurrences?"
    "The appointment.Id.UniqueID changed"
    "EWS API- Differences in ICalUid returned when appointments are created by Office 365 account vs. Microsoft Outlook Mac Client"
    "EWS: UID not always the same for orphaned instances of the same meeting"

    "Property: UID"
    "PidLidGlobalObjectId Canonical Property"
    "PidLidCleanGlobalObjectId Canonical Property"
    @987654328 @
    "Developer information about the calendar changes in Outlook 2003 Service Pack 2, in Exchange Server 2003 Service Pack 2, and in later versions of Exchange Server and of Outlook"

    "Working with extended properties by using the EWS Managed API 2.0"

    我无法具体说明要使用的代码,因为我们的应用程序是用 Delphi 编写的,并且仅使用 SOAP 调用来同步日历项

    【讨论】:

      【解决方案2】:

      您拥有的另一个选项是消息 ID 字段(来自 RFC 5322),即来自 Graph API message resource 的 internetMessageId。该 ID 在移动中保持不变。但是,它在副本中也保持不变,这可能是也可能不是您喜欢的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多