myButton.Picture = MyHost.GetIPictureDispFromPicture(MyForm.ImageList.Images(0));
This approach will work fine when you use Explorer. The same fails when you try to assign the picture property to a CommandBarButton on a CommandBar using Outlook Inspector. Just to inform, the Outlook object model also defines two interesting types i.e. Explorer and Inspector, which allows you to manipulate the user interface. An Explorer represents a window in which folder contents are displayed. An inspector represents a window that contains a specific Outlook item, such as an e-mail message or a contact, and any tabbed pages within the Outlook item (for example, the Details tab of a task item). The Application class maintains a collection of all Explorers and Inspectors, which can be obtained using the properties Explorers and Inspectors. You can get the currently active UI element by using methods GetActiveExplorer() and GetActiveInspector() of Application class.
Ok now let's come back to our original discussion point i.e. how to assign the Picture property to a CommandBarButton while using Outlook Inspector. Somehow the above approach doesn't work with Outlook Inspector.
However there is a workaround for the same. To set the Picture property to a CommandBarButton while using Outlook Inspector, you can use the ClipBoard object. ClipBoard exposes a method SetDataObject as shown below.
public
static void SetDataObject(object data, bool copy);
This method places data on the system clipboard and specifies whether the data should remain on the clipboard after the application exits (as indicated by the Boolean variable copy).
Now you can use following code to assign the picture property to a CommandBarButton while using Outlook Inspector.
Clipboard.SetDataObject(MyForm.ImageList.Images(0),