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
itemIdproperty is not available in compose mode. If an item identifier is required, thesaveAsyncmethod can be used to save the item to the store, which will return the item identifier in theAsyncResult.valueparameter in the callback function.
What I am doing wrong?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With