如何在outlook添加中放置工具栏图标

本文关键字:工具栏 图标 添加 outlook | 更新日期: 2023-09-27 18:13:58

我正在创建2007年的Outlook插件。这里我添加工具栏,并在工具栏上添加一个按钮。我要附加图标与按钮(按钮名称是导入)。,这里我写了一个函数getimage()来设置图标按钮图片属性。但是这里我没有工具栏按钮图标。所以请大家帮我解决这个问题,为什么我没有图标按钮

private void AddToolbar()
    {
        if (newToolBar == null)
        {
            Office.CommandBars cmdBars =
                this.Application.ActiveExplorer().CommandBars;
            newToolBar = cmdBars.Add("NewToolBar",
                Office.MsoBarPosition.msoBarTop, false, true);
        }
        try
        {                
            Office.CommandBarButton button_1 =
                (Office.CommandBarButton)newToolBar.Controls
                .Add(1, missing, missing, missing, missing);
            button_1.Style = Office
                .MsoButtonStyle.msoButtonCaption;
            button_1.Caption = "Import";
            button_1.Tag = "Button1";

      button_1.Picture = getImage();
            if (this.firstButton == null)
            {
                this.firstButton = button_1;
                firstButton.Click += new Office.
                    _CommandBarButtonEvents_ClickEventHandler
                    (ButtonClick);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
class ConvertImage : System.Windows.Forms.AxHost
{
    private ConvertImage()
        : base(null)
    {
    }
    public static stdole.IPictureDisp Convert
        (System.Drawing.Image image)
    {
        return (stdole.IPictureDisp)System.
            Windows.Forms.AxHost
            .GetIPictureDispFromPicture(image);
    }
}
    private stdole.IPictureDisp getImage()
    {
        stdole.IPictureDisp tempImage = null;
        try
        {
            System.Drawing.Icon newIcon =
                Properties.Resources.recruit_logo;
            ImageList newImageList = new ImageList();
            newImageList.Images.Add(newIcon);
            tempImage = ConvertImage.Convert(newImageList.Images[0]);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        return tempImage;
    }

如何在outlook添加中放置工具栏图标

在button.picture下面添加这一行button_1。