<p>We have been developing an Outlook Add-in using Visual Studio 2008. However I am facing a strange behavior while adding a command button to a custom command bar. This behavior is reflected when we add the button in the reply, reply all and forward windows. The issue is that the caption of the command button is not visible though when we debug using VS it shows the caption correctly. But the button is captionless when viewed in Outlook(2003).</p>

<p>I have the code snippet as below. Any help would be appreciated.</p>

<pre><code>private void AddButtonInNewInspector(Microsoft.Office.Interop.Outlook.Inspector inspector)
        {
            try
            {
                if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.MailItem)
                {


                    try
                    {                       
                        foreach (CommandBar c in inspector.CommandBars)
                        {
                            if (c.Name == "custom")
                            {
                                c.Delete();
                            }
                        }
                    }
                    catch
                    {
                    }
                    finally
                    {
                        //Add Custom Command bar and command button.
                        CommandBar myCommandBar = inspector.CommandBars.Add("custom", MsoBarPosition.msoBarTop, false, true);
                        myCommandBar.Visible = true;

                        CommandBarControl myCommandbarButton = myCommandBar.Controls.Add(MsoControlType.msoControlButton, 1, "Add", System.Reflection.Missing.Value, true);                        
                        myCommandbarButton.Caption = "Add Email";
                        myCommandbarButton.Width = 900;
                        myCommandbarButton.Visible = true;
                        myCommandbarButton.DescriptionText = "This is Add Email Button";

                        CommandBarButton btnclickhandler = (CommandBarButton)myCommandbarButton;
                        btnclickhandler.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.OnAddEmailButtonClick);
                    }


                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "AddButtInNewInspector");
            }
        }
</code></pre>

[{'answer_id': 24258, 'author': 'Ryan Farley', 'author_id': 1627, 'author_profile': 'https://Stackoverflow.com/users/1627', 'pm_score': 1, 'selected': False, 'text': '<p>I don\'t know the answer to your question, but I would highly recommend Add-In Express for doing the addin. See <a href="http://www.add-in-express.com/add-in-net/" rel="nofollow noreferrer">http://www.add-in-express.com/add-in-net/</a>. I\'ve used this in many projects, including some commercial software and it is completely awesome.  </p>\n\n<p>It does all the Outlook (and office) integration for you so you just work with it like any toolbar and just focus on the specifics of what you need it to do. You won\'t ever have to worry about the Outlook extensibility at all. Highly recommended.   </p>\n\n<p>Anyway, just wanted to mention it as something to look in to. It will definitely save some headaches if you\'re comfortable with using a 3rd party component in the project.</p>\n'}, {'answer_id': 107121, 'author': 'CtrlDot', 'author_id': 19487, 'author_profile': 'https://Stackoverflow.com/users/19487', 'pm_score': 0, 'selected': False, 'text': '<p>I don\'t know, but your code raises two questions:</p>\n\n<ol>\n<li><p>Why are you declaring "CommandBarControl myCommandbarButton" instead of "CommandBarButton myCommandbarButton"?</p></li>\n<li><p>Why are you setting the width to 900 pixels? That\'s huge. I never bother with this setting in Excel since it autosizes, and I\'m guessing the Outlook would behave the same.</p></li>\n</ol>\n'}, {'answer_id': 628969, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>You aren't setting the command bar button's style property (from what I can tell). </p>\n\n<p>This results in the button having an MsoButtonStyle of <strong>msoButtonAutomation</strong>. I have seen the caption fail to appear if the style is left at this.</p>\n\n<p>Try setting the Style property to <strong>msoButtonCaption</strong>.</p>\n"}]
['https://Stackoverflow.com/questions/24113', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2528/']