Outlook handles custom task panes a bit different to the other applications.
Outlook might reuse a custom task pane that was associated with an Inspector previously
This can sometimes result in having multiple custom task panes for the same Inspector.
To avoid this you should explicitly remove all custom task panes when the Inspector is closed.

Outlook.Inspectors inspectors; 

private void ThisAddIn_Startup()
   inspectors = Application.Inspectors;
   inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(event_NewInspector);

void event_NewInspector(Outlook.Inspector inspector)
   Microsoft.Office.Tools.CustomTaskPane pane = Globals.ThisAddIn.CustomTaskPanes.Add(new UserControl(),
   pane.visible = true;
   pane.visiblechanged += new EventHandler(pane_visiblechanged);

   //when you close an inspector, the visible changed event is not fired so use the Inspector_Close event
   ((Outlook..InspectorEvents_10_Event)inspector).Close += new Outlook.InspectorEvents_10_CloseEventHandler(event_InspectorClose);

void event_InspectorClose()
   ((Outlook..InspectorEvents_10_Event)inspector).Close -= new Outlook.InspectorEvents_10_CloseEventHandler(event_InspectorClose);
   pane = null;

private void ThisAddIn_Startup(object sender, System.EventArgs e) { 
    // Initialize variables.
    m_Application = this.Application;
    m_Explorers = m_Application.Explorers;
    m_Inspectors = m_Application.Inspectors;
    m_Windows = new List<OutlookExplorer>();
    m_InspectorWindows = new List<OutlookInspector>();

    // Wire up event handlers to handle multiple Explorer windows.
    m_Explorers.NewExplorer +=
        new Outlook.ExplorersEvents_NewExplorerEventHandler(
    // Wire up event handler to handle multiple Inspector windows.
    m_Inspectors.NewInspector +=
        new Outlook.InspectorsEvents_NewInspectorEventHandler(
    // Add the ActiveExplorer to m_Windows.
    Outlook.Explorer expl = m_Application.ActiveExplorer()
        as Outlook.Explorer;
    OutlookExplorer window = new OutlookExplorer(expl);

    // Hook up event handlers for window.
    window.Close += new EventHandler(WrappedWindow_Close);
    window.InvalidateControl += new EventHandler<

void WrappedWindow_InvalidateControl(object sender,
    OutlookExplorer.InvalidateEventArgs e) {
    if (m_Ribbon != null)

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext