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
ASKER CERTIFIED SOLUTION
theGhost_k8
Database Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 5 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 5 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004