在 outlook 邮件中发送邮件后,itemId 正在更改

itemId is changing after mail sent in outlook mail

我在撰写模式 saveAsync 之后收到了 itemId 个邮件项目。

邮件项目发送后,Office.context.mailbox.item.itemId 中的项目 Id 与撰写模式下给出的不同。

在撰写模式下用于获取 itemId 的代码:

var itemId = Office.context.mailbox.item.itemId;
if (itemId === null || itemId == undefined) {
    Office.context.mailbox.item.saveAsync(function (result) {
        itemId = result.value;
    });
}

电子邮件发送后,我使用以下方法从发件箱中验证了电子邮件的 itemId

`Office.context.mailbox.item.itemId`

令我惊讶的是它是不同的。

根据documentationitemId应该是一样的:

The itemId property is not available in compose mode. If an item identifier is required, the saveAsync method can be used to save the item to the store, which will return the item identifier in the AsyncResult.value parameter in the callback function.

我做错了什么?

首先请务必了解项目的 itemId 不是静态值。只要项目在 Exchange 中四处移动,ID 就会发生变化。来自 EWS documentation:

Identifiers in Exchange are opaque. For example, the EwsId is created from several pieces of information that are not important to you as the developer, but are important to Exchange.

至于为什么会这样,是因为saveAsync会导致邮件被保存到草稿文件夹中。发送时,项目首先移至发件箱,然后移至已发送项目文件夹。每个文件夹更改(草稿、发件箱和已发送邮件)都会导致 itemId 字段发生更改。