Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

itemId is changing after mail sent in outlook mail

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?

like image 585
Rajeev Avatar asked Oct 28 '25 04:10

Rajeev


1 Answers

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.

like image 185
Marc LaFleur Avatar answered Oct 30 '25 14:10

Marc LaFleur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!