I am developing an Outlook-AddIn that automatically decrypts emails. So basically, the AddIn changes some MailItem properties (subject, body, attachments) when new mail arrives. The problem is that when I save the item then the decrypted message is synchronized with the server, which is really bad for end-to-end-encryption... If I don't save the item, then the explorer pane still shows the encrypted message and searching for emails (decrypted subject or body) does not work.
My question is: How can I display and (locally) store the decrypted mailItem, so that all the usual features like email searching still work?
Is there a way to stop synchronization for specific emails in .ost?
One solution that I came up with is to store a copy of the MailItem in a local .pst store. But in that case the user has to handle the messages in two different stores (.ost and .pst), which is not very user friendly. The requirement is that the user has to change his usual behaviour as little as possible when reading emails.
private void Outlook_NewMailEx(object Item)
Outlook.MailItem mailItem = Application.Session.GetItemFromID((string)Item);
if (mailItem != null)
// decrypt the mailItem
mailItem.Subject = "decrypted subject";
mailItem.Body = "decrypted body";
// save mailItem LOCALLY
// (don't synchronize the decrypted message with the server)
I would be grateful for any help!
email encryption outlook outlook-addin