This project has moved. For the latest updates, please go here.

Outlook error -

Mar 6, 2015 at 6:31 AM
Edited Mar 6, 2015 at 6:32 AM
Hi,

When trying to run the following code during the COMAddin startup, it gave the error
"Target instance is not running" at the line (in bold) where I'm trying to the active instance.
Any ideas what could cause this error?
Thanks.
    private void Addin_OnStartupComplete(ref Array custom)
    {
            try
            {
                /* Exception happened here */
                Outlook.Application outApp = NetOffice.OutlookApi.Application.GetActiveInstance(true);

                Office.CommandBar commandBar = null;
                Office.CommandBarButton commandBarSaveBtn = null;

                // add a new toolbar
                commandBar = outApp.ActiveExplorer().CommandBars.Add("MyOutlook", MsoBarPosition.msoBarTop, false, true);
                commandBar.Visible = true;

                // add a button to the toolbar
                commandBarSaveBtn = (Office.CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarSaveBtn.Style = MsoButtonStyle.msoButtonIconAndCaption;
                commandBarSaveBtn.Caption = "Save to Local";
                commandBarSaveBtn.FaceId = 3;
                commandBarSaveBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(outlookSaveBtn_Click);

    }