I have the following problem with an Add-in I’m writing for outlook in VB.NET. I add an command button to the toolbar of the new mail window when the user creates a new mail. Now this works correctly, the button shows up and the events of the inspector object are fired correctly. The only problem is that the click event of the command button won't fire. If i use the same code to create a button in the main window it fires correctly. Any help would be greatly appreciated.
***Code***
Public Class ThisApplication
Private WithEvents oInspectors As Outlook.Inspectors
Private WithEvents oSendBulk As Office.CommandBarButton
Private WithEvents oMail As Outlook.MailItem
Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
oInspectors = Me.Inspectors
End Sub
Private Sub oInspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles oInspectors.NewInspector
'If the new inspector was created on an new mail event create the new toolbar button
If Inspector.CurrentItem.class = Outlook.OlObjectClass.olMail Then
'Create the toolbar button if it doesn't excist yet
Try
oButton = Inspector.CommandBars("Tools").Controls("Knopje")
Catch
oButton = Inspector.CommandBars("Tools").Controls.Add(, , , , True)
With oButton
.Caption = "Knopje"
End With
End Try
oMail = Inspector.CurrentItem
End If
End Sub
Private Sub oSendBulk_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles oSendBulk.Click
MsgBox("Boing")
End Sub
End Class
.onaction and .TAG