Event Handlers

When adding event handlers to any Outlook object, such as the Explorers and Inspectors collections or the Explorer and Inspector objects, you have to retain a reference to those items in your add-in. The reason for this is because the objects presented to the add-in by Outlook are not the actual objects, but rather interface objects providing limited access to the actual underlying objects. When the object goes out of scope it is discarded. Every time you get a reference, it's a new interface object so you never actually see the same object twice. Thus if you do not save a reference, your event handlers are discarded and garbage collected. Thus they don't throw events or at least not for long.

Comments

Popular Posts