exchange-serverexchangewebservicesews-managed-apiexchange-server-2016exchange-server-2019

How can i find the permanent id of an email in EWS managed API?


I am building an application that filters through all the emails in a user's mailbox and then moves the results in a Quarantine folder for further review. However, when moving, the original item(email) is deleted and a new item is created with a new ItemId. I have read the documentation but i could not find anything mentioning about a permanent id that doesn't change when moving/copying.

Is there a way to set the id manually? I looked into AlternateID and it looks like it might be one solution.

I use EWS Managed API(.NET Framework) in Exchange 2019.


Solution

  • EWS doesn't have an immutableId for messages so when a message moves between folders it will change. You can use the InternetMessageId which won't change when a message is moved but it's not guaranteed to be unique. PidTagSearchKey is another one https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagsearchkey-canonical-property this should be globally unique and won't change when you move an Item between folder. The change you need to make however is that you now need to search for the messages based on one of these Id's you won't be able to bind to the item directly as in the case of the ewsId.