How to handle the Open event of a mail item in VB.NET?

M

MeAgin

Hi all,



How to handle the Open event of a mail item in VB.NET?
I want to display a message when a mail item is opened.
I achieved this in VBA using the Inspector_Activate() event. But when I
write the same code using VB.NET for my add-in it doesn't work.


Following is the code used,



Imports System.IO



Public Class ThisApplication

Public WithEvents VBAInspectors As Outlook.Inspectors

Public WithEvents VBAInspector As Outlook.Inspector



Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup

VBAInspectors = Me.Inspectors

End Sub



Private Sub ThisApplication_Shutdown(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Shutdown

End Sub



Private Sub VBAInspector_Activate()

MessageBox.Show("Opening a mail...")

End Sub



Private Sub VBAInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)

VBAInspector = Inspector

End Sub



End Class



Any help is appreciated,

Nadee
 
K

Ken Slovak - [MVP - Outlook]

The signatures on your event handlers don't look correct.

For example, the NewInspector event handler should have:
Handles VBAInspectors.NewInspector
after the closing parenthesis of the event handler declaration.

The Inspector.Activate event handler should have:
Handles VBAInspector.Activate
after the closing parenthesis.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top