The image will be embedded into the add-in assembly automatically.Ĭ# and Add-in Express: using System.Drawing // private void SetUpFolder (Outlook.
Note that I have included an image to the resources of each add-in project, so you won’t need to include it in the setup package manually.
#DIM DESKTOP ICON MANAGER CODE#
You can also download a complete solution which contains all the code including auxiliary code needed for converting images into the IPictureDisp interface.
So, we need to find a folder first and only then, if there is folder with the same name, create it.īelow you can find a snippet of code developed in C# and VB.NET for VSTO and Add-in Express based add-ins. Note that if you try to add a folder and such a folder already exists, you will get an exception saying the folder cannot be created: It accepts an instance of the MAPIFolder class for which an icon should be set. The SetCustomIcon method – is used for setting a custom icon for an Outlook folder (the name of our custom folder is “Smiling Folder”).The method accepts an instance of the Outlook Application. If a folder with the same name already exists we just need to find it. The SetUpFolder method – is used for creating a new folder if no such folder was created earlier.
#DIM DESKTOP ICON MANAGER HOW TO#
Of course, I have prepared a sample code which shows how to set a custom icon for an Outlook folder. Then I close Outlook and when I reopen it anew (without the code which was used for creating a folder and setting an icon), no icon is there: For example, I created a folder and set a custom icon for it. That is why you need to set an icon on each Outlook startup. So, if you programmatically set an icon and then close Outlook, there will be no icon when you open it anew. I would like to draw your attention to the fact that Outlook doesn’t store the icon set during a previous session. An exception will be thrown in the SetCustomIcon method in this case. Only the in-process code can be used for such a task. The Outlook Object Model doesn’t allow setting a custom icon for a folder from another application (using the OLE Automation technology). The same technique is used for solutions module folders. Special folders (see the OlSpecialFolders enumeration)Īs you might have noticed there are no search folders on the list, which means you can set custom icons for Search folders.Default folders (see the OlDefaultFolders enumeration).For example, I have tried to set a custom icon for the Inbox folder and immediately got the “Custom folder icon is not allowed…” exception:Ī custom icon cannot be added to the following groups of folders in Outlook: Not all folders allow you to set a custom icon. Not all Outlook folders accept custom icons Outlook can scale up icons if a small image was set and Outlook is running in high DPI mode. An appropriate size will be used depending on the DPI (Dots Per Inch) mode set on the PC. Also you can find the sample solution (available for download at the end of article) which contains the entire code needed to get the job done.Īllowed types of images are icons and bitmaps. Net based classes to the IPictureDisp interface. The VBA help reference (as well as the Outlook Object Model reference) provides a code to convert instances of. The SetCustomIcon method accepts an instance of the IPictureDisp interface and doesn’t return anything. However, today we will focus our attention on the setting a custom icon. This class also provides the opposite method for getting a custom icon – GetCustomIcon. The SetCustomIcon method is available at the MAPIFolder class level. So, let’s start our journey into the Outlook programming world -) Setting custom icons in Outlook – a bit of theory The Outlook Object Model provides a special method for this task – SetCustomIcon. Now Outlook allows setting custom icons the Navigation pane folders.
Dear reader, today I want to show you one of the new features Outlook 2010 brought to programmers.