When you create a custom task pane for Outlook, the custom task pane is associated with a specific Explorer or Inspector window. Explorers are windows that display the contents of a folder, and Inspectors are windows that display an item such as an e-mail message or a task.
If you want to display a custom task pane with multiple Explorer or Inspector windows, you need to create a new instance of the custom task pane when an Explorer or Inspector window opens. To do this, handle an event that is raised when an Explorer or Inspector window is created, and then create the task pane in the event handler. You can also handle Explorer and Inspector events to hide or display task panes depending on which window is visible.
To associate the task pane with a specific Explorer or Inspector, use the CustomTaskPaneCollection..::.Add(UserControl, String, Object) method to create the task pane, and pass the Explorer or Inspector object to the window parameter. For more information about creating custom task panes, see Custom Task Panes Overview.
For a walkthrough that demonstrates how to create a task pane for every e-mail message that is opened, see Walkthrough: Displaying Custom Task Panes with E-Mail Messages in Outlook.
Outlook Events
To monitor the state of Explorer windows, you can handle the following Explorer-related events:
To monitor the state of Inspector windows, you can handle the following Inspector-related events:
Preventing Multiple Instances of a Custom Task Pane in Outlook
To prevent Outlook windows from displaying multiple instances of a custom task pane, explicitly remove the custom task pane from the CustomTaskPanes collection of the ThisAddIn class when each window is closed. Call the Remove method in an event that is raised when a window is closed, such as ExplorerEvents_10_Event..::.Close or InspectorEvents_10_Event..::.Close.
If you do not explicitly remove the custom task pane, Outlook windows might display multiple instances of the custom task pane. Outlook sometimes recycles windows, and recycled windows retain references to any custom task panes that were attached to them.