itemId is changing after mail sent in outlook mail

ぃ、小莉子 提交于 2019-12-24 01:53:56

问题


I am getting itemId of a mail item after saveAsync in compose mode.

Once mail item is sent, item Id coming in Office.context.mailbox.item.itemId is different than what is given in compose mode.

Code used for getting itemId in compose mode:

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

After the email is sent, I verified email's itemId from sent box using:

`Office.context.mailbox.item.itemId`

to my surprise it is different.

According to the documentation, the itemId should be the same:

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.

What I am doing wrong?


回答1:


First it is important to understand that an item's itemId is not a static value. The ID will change whenever an item is moved around in Exchange. From the 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.

As to why this is happening, it is because saveAsync will result in the email being saved to the Drafts folder. When it is sent the item first moved to the Outbox and then into the Sent Items folder. Each of those folder changes (Drafts, Outbox, and Sent Items) results in a change to the itemId field.



来源:https://stackoverflow.com/questions/46076151/itemid-is-changing-after-mail-sent-in-outlook-mail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!