troubleshooting Question

Outlook Add-in Commandbar Problems

Avatar of CADMatch
CADMatch asked on
Visual Basic.NET
5 Comments1 Solution254 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros