Search code examples
.netexchange-serverexchangewebservicesexchange-server-2019

Restoring emails from a Quarantine folder EWS


I have implemeted a feature that filters emails and moves the emails that meet a certain criteria to a "Quarantine" folder where they will be reviewed and if they are deemed safe, they will be restored in the original folder.

The problem i have is that in the quarantine folder i will probably have emails from a lot of different folders, not just Inbox.

Is there a way to find out in what folder was the email originally stored so it can go back upon restoring?

I will also point out that upon moving/copying an email, a new Item is created in the destination folder with a new ItemId.

I am using EWS Managed API (.NET Framework) in Exchange(on-premise) 2019.


Solution

  • If the folder is in the same mailbox the the LastActiveParentEntryID https://techcommunity.microsoft.com/t5/exchange-team-blog/announcing-original-folder-item-recovery/ba-p/606833 should be able to be used to find the folder it was moved from eg https://gsexdev.blogspot.com/2018/10/using-lapfid-last-active-parent.html