Resolved: Outlook Ribbon on Click Event not working

In this post, we will see how to resolve Outlook Ribbon on Click Event not working


I have a simple Outlook Ribon button I am trying to create to forward a selected email to a set address. The probelm is when I click the button, it is not runing the code. I tried adding several break points and they never happen, even on the If statment below. Does anyone have any ideas?
I have not worked with Visual Basic .NET in several years, and I feel like it must be something simple I am missing.
Full Project Link if wanted:
I tried break points in multible places. I looked at multble example sites to see if code was correct.

Best Answer:

You have two handlers in your code for the Button1.Click event:
Correct signature
Incorrect signature
The second version (with the incorrect signature) is where your code is. There is no event with that signature, so it never gets called. The first version (with the correct signature) has no code in it to run, so that’s why you’re not seeing anything happen.
It looks like you ended up with the double handlers because you were trying to get a reference to the current Outlook.MailItem using something similar to this:
That won’t work. Here’s the correct syntax:
Once you’ve got it working the way you want it, you can delete that other handler altogether.

If you have better answer, please add a comment about this, thank you!