Assign Outlook Categories to a RibbonMenu with buttons

417 Views Asked by At

I am currently creating a Outlook Add-in and need to include the Outlook Catagorize Menu to my add-in. With this Foreach I´m Creating and adding the Buttons manually into the "Kategorisieren"-RibbonMenu and naming them the same as the catagory names. Now I´m trying to copy the color-images of the categories to the button Image which works by assigning them with the right OfficeImageId. Nevertheless there are some catagories which colors are not described as OfficeImageIds, but rather like objects f. e. the color peach as an object of OlCategoryColor.OlCategoryColorPeach . The Problem is that I cant use them as the others by assigning them to the button.Image or OfficeImageId. How do I get these little Icons in the right Color next to my buttons.

The next Task would be assigning the Category to the Appointment by clicking on the right button.

Categories categories = Globals.TerminAddIn.Application.Session.Categories;

foreach (Category category in categories)
                {
                    var button = this.Factory.CreateRibbonButton();
                    this.Kategorisieren.Items.Add(button);
                    button.Label = category.Name;
                }

 this.Kategorisieren.ControlSize = RibbonControlSize.RibbonControlSizeLarge;
 this.Kategorisieren.OfficeImageId = "CategorizeMenu";
 this.Kategorisieren.ShowImage = true;

1

There are 1 best solutions below

2
On

I'd recommend using the ribbon XML with callbacks where you can define the button's images and labels. At any point in time, you can update the buttons list or change categories with colors. Read more about this approach in the Walkthrough: Create a custom tab by using Ribbon XML article.

When you customize the Ribbon UI by using callback procedures, for each of the callbacks the add-in implements, the responses are cached. For example, if an add-in writer implements the getImage callback procedure for a button, the function is called once, the image loads, and then if the image needs to be updated, the cached image is used instead of recalling the procedure. This process remains in-place until the add-in signals that the cached values are invalid by using the Invalidate method, at which time, the callback procedure is again called and the return response is cached.

The Fluent UI (aka Ribbon UI) is described in-depth in the following series of articles: