Adding A Custom Icon to Outlook AddIn’s Context Menu Using C#

This post is continuing the previous outlook addin post (https://lemeaow.wordpress.com/2013/02/13/creating-outlook-2010-addin-with-c/).

1. To create a custom mini icon on the left of the context menu, add the following to MyRibbon.cs.

 public Bitmap LoadImage(string imageName)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream stream = assembly.GetManifestResourceStream("MyAssemblyName." + imageName);

            return new Bitmap(stream);
        }

2. Then, add the image  resources to the project as an embedded resources.

embedded_resources

3. Modify the button definition in Explorer.xml to include the icon:

<button id="btnId" image="img.png"
              label="Test"
              onAction="OnMyButtonClick"/>

Bonus Tip : You can also use MS’s default icons. In this case, you don’t need to do step (1) or (2) and add the following line to the Explorer.xml instead:

<button id="btnId" imageMso="HappySmile"
              label="Test"
              onAction="OnMyButtonClick"/>

You can find the list of mso ids from this site : http://soltechs.net/CustomUI/imageMso01.asp?gal=2&count=no .

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: