Search code examples
c#outlookvstooutlook-addin

Outlook VSTO recipients changed event


I am working on an Outlook Addin written in C#. I need to implement some business logic when the recipients are changed. From my research there is not an event for this in VSTO. I tried with the PropertyChanged event from MailItem, but is firing too many times. If I pasted 2 emails in recipients then fires for every email 3 times for TO, BCC, CC. This doesn't help me. Is there a way to know when the user types in recipients fields or to make the property changed events not to fire so many times?


Solution

  • You can use a timer for that - when the event fires, reset the timer (disable/enable). Do the processing only in the timer event - this way you will process the recipients only once after a timeout.

    See https://social.msdn.microsoft.com/Forums/vstudio/en-US/417d026c-4486-4273-b346-94e20dad4796/propertychange-event-and-mailtitem-properties?forum=outlookdev