Here’s some sample code:
private Outlook.Application applicationObject;
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
{
MessageBox.Show("on connection");
applicationObject = (Outlook.Application)application;
applicationObject.Explorers.NewExplorer += new Microsoft.Office.Interop.Outlook.ExplorersEvents_NewExplorerEventHandler(Explorers_NewExplorer);
}
void Explorers_NewExplorer(Microsoft.Office.Interop.Outlook.Explorer Explorer)
{
MessageBox.Show("new explorer");
}
the “new explorer” message never appears on the screen because the NewExplorer event never fires, not even when I click on “Open in New Window”.
What could be wrong?
The
Explorersinstance on which you’re subscribing to theNewExplorerevent is probably getting garbage-collected. To prevent this from happening, preserve a reference to it through an instance variable: