1
votes

I use this code...

Dim inspectors As Outlook.Inspectors = Outlook.Application.Inspectors
AddHandler inspectors.NewInspector, AddressOf Inspectors_NewInspector

... to add my custom panel to a net mailitem.

But if I use the snipping tool in windows and tell it to email the snippet, then NewInspector is not called eventhough a new mail is created.

Any idea why NewInspector is not called?

Thanks

UPDATE WITH CODE:

Here's a simple sample code. Sending a mail from an external program (like Word, Excel, Snipping tool etc) does not call the NewInspector event...

Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop.Outlook
Imports Microsoft.Office.Tools
Imports Outlook = Microsoft.Office.Interop.Outlook

Public Class ThisAddIn    

    Private WithEvents _inspectors As Outlook.Inspectors

    Private Sub ThisAddIn_Startup() Handles Me.Startup
        _inspectors = Globals.ThisAddIn.Application.Inspectors
    End Sub

    Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    End Sub

    Private Sub _inspectors_NewInspector(Inspector As Inspector) Handles _inspectors.NewInspector
        MsgBox("New inspector")
    End Sub

End Class
2

2 Answers

1
votes

NewInspector event does not fire for the inspectors created using Simple MAPI or mailto links (this is by design). You can have a timer that periodically loops over the Application.Inspectors collection to check if there is a new inspector not yet handled by your code.

0
votes

You need to declare inspectors variable on the global (class) level to make sure it is not garbage collected.