Reputation: 236
I have a problem setting an image to the custom context menu item in the outlook. I have a strong requirement to use a custom image, that i was provided.
That's how i'm doing it right now:
Application.ItemContextMenuDisplay += ApplicationItemContextMenuDisplay;
...
private void ApplicationItemContextMenuDisplay(CommandBar commandBar, Selection selection)
{
var contextButton = commandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true) as CommandBarButton;
contextButton.Picture = ImageConverter.ImageToPictureDisp(Resources.ContextMenuIcon);
contextButton.Visible = true;
contextButton.Caption = Resources.ArchiveMail;
contextButton.Click += ArchiveButtonClicked;
}
My image converter looks like this:
public class ImageConverter : AxHost
{
public ImageConverter() : base("59EE46BA-677D-4d20-BF10-8D8067CB8B33")
{
}
public static IPictureDisp ImageToPictureDisp(Image image)
{
return (IPictureDisp) GetIPictureDispFromPicture(image);
}
}
The image i'm using is bmp (16*16, 8 bit).
the problem is that there's no image in the outlook context menu for my new item. The button appears, it does what i want it to do, but no image is shown. And no exception is thrown. What can that be?
Upvotes: 1
Views: 1810