Develop Office Client Applications using Visual Studio
You can add a custom group to the Message tab of an Outlook mail item. For example, here is a custom group named "MyCoolGroup" that I added to the message tab of a new message:
Outlook lets you open a message in the following two modes:
Making a custom group appear for only one of these modes is pretty easy. Making it appear for both modes is a tad more challenging. That is because the control ID of the Message tab in read mode is different than the control ID of the Message tab in compose mode. When you design your custom group in the VSTO Ribbon designer, you can only specify one control ID. This means that when you run the project, the custom group will only appear in the Message tab of a compose window or the Message tab of a read window depending on which control ID you specify at design-time.
If you want the group to appear in both versions of the Message tab (read and compose), you have to do a bit more work. Here is how you make the group appear for both modes:
First, add a Ribbon (Visual Designer) to an Outlook 2007 add-in project.
Then, set the RibbonType property of the Ribbon to Microsoft.Outlook.Mail.Read as follows:
On the Ribbon designer, add a group to a tab and customize the group as desired.
On the Ribbon designer, select the tab, open the Properties window, and then set the OfficeId of the tab to TabReadMessage. TabReadMessage is the control ID of the default tab that appears on the Ribbon of a mail message that is open in read mode.
Ok. Now when you run the project, your custom group will appear only if you open a mail item in read mode. Now you need to add second Ribbon to your project to display this custom group in a mail item that is open in compose mode.
Add a second Ribbon (Visual Designer) to the project. Then, set the RibbonType property of the Ribbon to Microsoft.Outlook.Mail.Compose as follows:
On the Ribbon designer, select the tab of the second Ribbon, open the Properties window, and then set the OfficeId of the tab to TabNewMailMessage. TabNewMailMessage is the control ID of the default tab that appears on the Ribbon of a mail message that is open in compose mode.
I know what your thinking. Do you mean I have to create two separate custom groups? That defeats the whole point of trying to do this right? Yes that would. Fortunately, you don’t have to create two custom groups. You only have to create two Ribbons as I have shown here. You can use the same custom group in both Ribbons. Here is how:
Open the first Ribbon that you created in the Ribbon Designer. In the Ribbon Designer, select your custom group. In the Properties window, set the Modifiers property of the group to Public.
Open the code file of the second Ribbon that you created (called Ribbon2 in my project).
In the constructor of the second Ribbon, add the custom group from Ribbon1 to Ribbon2 as follows:
Ribbon1 firstRibbon = new Ribbon1();
You can read more about adding custom groups to built-in tabs in the following MSDN articles:
How to: Customize a Built-in tab
How to: Get Started Customizing the Ribbon
Customizing a Ribbon for Outlook
Perfect. Just what I was looking for. Thanks!
Thank you for this article! It is exactly what I wanted to know!