Prevent prompting about saving changes when adding a UserProperty

Add-in Express™ Support Service
That's what is more important than anything else

Prevent prompting about saving changes when adding a UserProperty

Posts: 50
Joined: 2018-03-13

I am developing a VSTO Outlook Add-in and using UserProperties of Outlook item (Outlook.MailItem, Outlook.MeetingItem etc.) to store some necessary data.

When a user opens a new item in an Inspector and perform some manipulations on my Add-in then my code adds a UserProperty to the item. Outlook detects these changes and when the user closes the Inspector then 'Want to save your changes' pop-up message is shown. This is confusing as the user has't modified the item itself...

This problem can be solved if I call Save() method on the Outlook item right after adding a UserProperty. But then another issue occurs: when the user does make some changes on the item (subject, recipients and so forth) and then closes the Inspector then the pop-up message 'Want to save your changes' is NOT shown (as the item has been saved programmatically) that is not correct.

So, as I see Outlook interprets item changes made by user on UI and changes of UserProperies made programmatically in the same way.

My question is whether it is possible for Outlook to distingush these two types of changes of Outlook Item so that users are not asked about saving changes that they have not made and opposite.

Maybe, you have faced such a problem before. I will be grateful for any advice. Thank you.
Posted 10 Dec, 2020 09:10:45 Top
Andrei Smolin

Add-in Express team

Posts: 18338
Joined: 2006-05-11
Hello Igor,

I'd try to use the MailItem.Send event to modify the email. To identify it, I'd use the HWND of the email's Inspector window: see GetActiveWindow() in Windows API.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 11 Dec, 2020 02:38:28 Top