Outlook Add-In: How to add a menu item to an existing tab on a read mail message


Basically, I want to add a button onto an existing tab when a user reads a mail message. In my case, this is so I can create a Jira issue from the email message without having to open a browser, copy and paste all of the text I want, etc. Once you’ve created your Outlook add-in project, add a Ribbon (can be graphical). On your tab, set the “OfficeId” to “TabReadMessage”. This will tell Outlook to take your tab group and put it on the existing “Message” tab. You can click on your ribbon and view the properties to see the OfficeId.

Once you’ve done this, the next step is likely you needing access to the mail message to extra the information from it you want. Here’s the basic code. Note, this code works but it’s not production ready. I’m not error checking, I’m letting VB handle the casting for me and I don’t provide useful error messages for a user (that said, it works, you can add the rest). This will give you a MailItem object that has the contents of the mail that you’re looking at. From here it’s up to you what to do. I shell an existing WinForm I have that connects to the Jira WebService and creates my issue. Hope this helps someone!

Dim currentInspector As Microsoft.Office.Interop.Outlook.Inspector = Me.Context
    
If currentInspector Is Nothing Then
    MsgBox("Null insepector")
    Exit Sub
End If
    
Dim mailItem As Microsoft.Office.Interop.Outlook.MailItem = currentInspector.CurrentItem
    
If mailItem Is Nothing Then
    MsgBox("Null MailItem")
    Exit Sub
End If

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.