Events

There are a number of events on the Application object. You can write code in the ItemSend event handler to perform actions or verify data before an item (such as an e-mail message, task, or meeting request) is sent. Or you can use either the NewMail event or the NewMailEx event to perform actions when a new mail item is received and added to the inbox. The main difference between these two events is that with NewMailEx, you can get information about each of the items received based on its ID. Figure 10.12 shows all the events available on the ThisApplication class.

tf Startup

d

j ¡(Declarations)

j AdvancedSearchComplete

J AdvancedSearchStopped

-f BindingContextChanged

J Disposed

Sltem5end

y MAPILogonComplete ■/ NewMail y NewMailEx y OptionsPagesAdd

QuitEvent y Reminder v Shutdown / Startup y StartupEvent y MAPILogonComplete ■/ NewMail y NewMailEx y OptionsPagesAdd

QuitEvent y Reminder v Shutdown / Startup y StartupEvent

Figure 10.12. Events available on the ThisApplication class

You should use the Shutdown event handler rather than QuitEvent, because the add-in is unloaded before this event is raised (and thus the event cannot be raised).

There are a number of events for Inspectors and Explorers as well as for the items that are available to your VSTO add-in solution. You can use the Activate and Deactivate events for either an Inspector or an Explorer. For example, there are additional events for Inspectors and Explorers related to size and position, such as BeforeMinimize, BeforeSize, and BeforeMove. Collections, such as Folders, have events when folders are added, removed, or changed, and Items have events when items are added, removed, or deleted.

0 0

Post a comment