I have created an Outlook add-in. When any mail is opened/previewed in Outlook, I want my add-in to update the body of the mail. And when the mail is closed or the preview is closed, I want the changes to be reverted back to the original changes.
For this I have tracked the SelectionChange event. Inside its handler:
- I have obtained the Active Explorer using mApp->ActiveExplorer(&mExplorer) function
- Then obtained selection from explorer using mExplorer->get_Selection(&lSelection)
- Then obtained the mail item from Selection using QueryInterface()
- On this mail item, I am updating the body using put_HTMLBody() function
Now, when the user clicks on any other mail, I want to discard the changes I made. However, the mail item gets saved and Outlook also creates another mail as well.
I want to discard the changes in all cases like if the user double clicks and opens the mail and closes it.
How can I discard the changes made to any mail item?