This project has moved. For the latest updates, please go here.

Outlook: Cannot register NewExplorerEvent

Jul 15, 2013 at 1:57 PM
Edited Jul 15, 2013 at 3:34 PM
Hello,

I'm having troubles registering the NewExplorer event in an Outlook AddIn. What I want to do is to add a new ribbon tab only on the ReadMail explorer in Outlook. Using the Microsoft API I am registering the event like this:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
       // Register NewExplorer event
        this.Application.Explorers.NewExplorer += new Outlook.ExplorersEvents_NewExplorerEventHandler(Explorers_NewExplorer);
            
 }
Unfortunately I couldn't find something similar in NetOffice.OutlookApi.Outlook.Application.Explorers, there is no NewExplorer event there (NetOffice 1.6). I tried the following without success, because explorers is always null:
void Addin_OnStartupComplete(ref Array custom)
{
    NetOffice.OutlookApi.Explorers explorers = NetOffice.OutlookApi.Explorers.GetActiveInstance();
    explorers.NewExplorerEvent += new Outlook.Explorers_NewExplorerEventHandler(Explorers_NewExplorer);
}
Am I missing something?

Thanks in advance.

Regards,
Vasil
Coordinator
Jul 15, 2013 at 8:00 PM
Explorers doesnt support the GetActiveInstance method.
GetActiveInstance enumerate all proxies from the RunningObjectTable(ROT) and Outlook doesnt use the ROT for the Explorers class. but you can use th classic way of course.

[NetOffice 1.6]
public class Addin : COMAddin
{
    public Addin()
    {
        this.OnStartupComplete += new OnStartupCompleteEventHandler(Addin_OnStartupComplete);
    }

    void Addin_OnStartupComplete(ref Array custom)
    {
        Explorers explorers = Application.Explorers as Explorers;
        explorers.NewExplorerEvent += new Explorers_NewExplorerEventHandler(Explorers_NewExplorerEvent);
    }

    void Explorers_NewExplorerEvent(_Explorer Explorer)
    {
        Explorer.Dispose();
    }
}
Jul 16, 2013 at 12:57 PM
Great, thanks for your help! It works exactly as I wanted.

Vielen Dank für die schnelle Antwort!