Beispiel #1
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Supress.Enabled = true;

                if (application.Session.EntityIsAvailable("SendAndReceive"))
                    application.Session.SendAndReceive(false);
                else
                    return new TestResult(false, DateTime.Now.Subtract(startTime), "SendAndReceive is not supported from this Outlook Version.", null, "");

                return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
                NetOffice.OutlookSecurity.Supress.Enabled = false;
            }
        }
Beispiel #2
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Supress.Enabled = true;

                // enum contacts 
                Outlook.MAPIFolder contactFolder = application.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
                for (int i = 1; i <= contactFolder.Items.Count; i++)
                {
                    Outlook.ContactItem contact = contactFolder.Items[i] as Outlook.ContactItem;
                    if (null != contact)
                        Console.WriteLine(contact.CompanyAndFullName);
                }

                return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, string.Format("{0} ContactFolder Items.", contactFolder.Items.Count));
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
                NetOffice.OutlookSecurity.Supress.Enabled = false;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Occurs when Outlook quits.
 /// </summary>
 private static void Outlook_Quit()
 {
     s_outlookApplication.QuitEvent -= Outlook_Quit;
     s_outlookApplication.Dispose();
     s_outlookApplication = null;
     s_mapiFolder = null;
 }
Beispiel #4
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Suppress.Enabled = true;

                if (application.Session.EntityIsAvailable("SendAndReceive"))
                {
                    application.Session.SendAndReceive(false);
                    // give few seconds to outlook or may its failed to quit because its busy - depending on how many mails comes in
                    System.Threading.Thread.Sleep(3000);
                }
                else
                    return new TestResult(false, DateTime.Now.Subtract(startTime), "SendAndReceive is not supported from this Outlook Version.", null, "");

                return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
            }
        }
Beispiel #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            Outlook.Application application = new Outlook.Application();

            // Get inbox
            Outlook._NameSpace outlookNS = application.GetNamespace("MAPI");
            Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

            for (int i = 1; i <= 100; i++)
            {
                labelCurrentCount.Text = "Step " + i.ToString();
                Application.DoEvents();
                if (_cancel)
                    break;

                // fetch inbox
                ListInBoxFolder(inboxFolder);
            }

            labelCurrentCount.Text = "Done!";

            // close outlook and dispose
            application.Quit();
            application.Dispose();
        }
Beispiel #6
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Supress.Enabled = true;

                // Create a new MailItem.
                Outlook.MailItem mailItem = application.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;

                // prepare item and send
                mailItem.Recipients.Add("*****@*****.**");
                mailItem.Subject = "NetOffice Test Mail";
                mailItem.Body = "This is a NetOffice test mail from the MainTests.(C#)";
                mailItem.Send();

                return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
                NetOffice.OutlookSecurity.Supress.Enabled = false;
            }
        }
Beispiel #7
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook
            Outlook.Application outlookApplication = new Outlook.Application();

            // get inbox 
            Outlook._NameSpace outlookNS = outlookApplication.GetNamespace("MAPI");
            Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);

            // setup gui
            listViewInboxFolder.Items.Clear();
            labelItemsCount.Text = string.Format("You have {0} e-mails.", inboxFolder.Items.Count);

            // we fetch the inbox folder items.
            foreach (COMObject item in inboxFolder.Items)
            {
                // not every item in the inbox is a mail item
                Outlook.MailItem mailItem = item as Outlook.MailItem;
                if (null != mailItem)
                {
                    ListViewItem newItem = listViewInboxFolder.Items.Add(mailItem.SenderName);
                    newItem.SubItems.Add(mailItem.Subject);
                }
            }

            // close outlook and dispose
            outlookApplication.Quit();
            outlookApplication.Dispose();
        }
Beispiel #8
0
 static void Main(string[] args)
 {
     Console.WriteLine("Concept Test - SuppressOutlookSecurity");
     Suppress.Enabled = true;
     Suppress.OnAction += new Suppress.SecurityDialogAction(Suppress_OnAction);
     Suppress.OnError += new Suppress.ErrorOccuredEventHandler(Suppress_OnError);
     Outlook.Application application = null;
     try
     {
         application = new Outlook.Application();
         SendMail(application);
         Console.WriteLine("Press any key...");
         Console.ReadKey();
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.ToString());
     }
     finally
     {
         if (null != application)
         {
             application.Quit();
             application.Dispose();
         }
     }
 }
Beispiel #9
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Supress.Enabled = true;

                Outlook.TaskItem newTask = application.CreateItem(OlItemType.olTaskItem) as Outlook.TaskItem;
                newTask.Subject = "Test item";
                newTask.Body = "hello";
                newTask.DueDate = DateTime.Now;
                newTask.Importance = OlImportance.olImportanceHigh;
                newTask.Close(OlInspectorClose.olDiscard);

                return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
                NetOffice.OutlookSecurity.Supress.Enabled = false;
            }
        }
Beispiel #10
0
 void IDTExtensibility2.OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
 {
     try
     {
         _outlookApplication = new Outlook.Application(null, Application);
     }
     catch (Exception exception)
     {
         string message = string.Format("An error occured.{0}{0}{1}", Environment.NewLine, exception.Message);
         MessageBox.Show(message, _prodId, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #11
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Supress.Enabled = true;

                // Get inbox 
                Outlook._NameSpace outlookNS = application.GetNamespace("MAPI");
                Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
              
                Outlook._Items items = inboxFolder.Items;
                COMObject item = null;
                int i = 1;
                do
                {
                    if (null == item)
                        item = items.GetFirst() as COMObject;

                    // not every item is a mail item
                    Outlook.MailItem mailItem = item as Outlook.MailItem;
                    if (null != mailItem)
                        Console.WriteLine(mailItem.SenderName);
                    
                    if(null != item)
                        item.Dispose();

                    item = items.GetNext() as COMObject;
                    i++;
                } while (null != item);
              
                return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, string.Format("{0} Inbox Items.", items.Count));
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
                NetOffice.OutlookSecurity.Supress.Enabled = false;
            }
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            Console.WriteLine("Create 3x Outlook Application");

            Outlook.Application application1 = new Outlook.Application();
            Outlook.Application application2 = new Outlook.Application();
            Outlook.Application application3 = new Outlook.Application();

            Console.WriteLine("Done! Press any key");
            Console.ReadKey();

            application1.Dispose();
            application2.Dispose();
            application3.Dispose();

            Console.WriteLine("Finish! Press any key..");
            Console.ReadKey();
        }
Beispiel #13
0
        private static void TestOutlook()
        {
            Console.WriteLine("Test Outlook Application Utils");

            Outlook.Application application = new Outlook.Application();
            Outlook.Tools.Utils.CommonUtils utils = new Outlook.Tools.Utils.CommonUtils(application);

            bool visible1 = utils.Application.Visible;
            application.Session.GetDefaultFolder(Outlook.Enums.OlDefaultFolders.olFolderInbox).Display();
            System.Threading.Thread.Sleep(3000);
            bool visible2 = utils.Application.Visible;

            application.Quit();
            application.Dispose();

            if(!(false == visible1 && true == visible2))
                throw new Exception("Unexpected outlook visibility");
        }
Beispiel #14
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook
            Outlook.Application outlookApplication = new Outlook.Application();

            // create a new MailItem.
            Outlook.MailItem mailItem = outlookApplication.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;

            // prepare item and send
            mailItem.Recipients.Add(textBoxReciever.Text);
            mailItem.Subject = textBoxSubject.Text;
            mailItem.Body = textBoxBody.Text;
            mailItem.Send();

            // close outlook and dispose
            outlookApplication.Quit();
            outlookApplication.Dispose();

            _hostApplication.ShowFinishDialog("Done!", null);
        }
Beispiel #15
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Supress.Enabled = true;

                Outlook.MailItem mailItem = application.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;
                mailItem.CloseEvent += new NetOffice.OutlookApi.MailItem_CloseEventHandler(mailItem_CloseEvent);

                // BodyFormat is not available in Outlook 2000
                // we check at runtime is property is available
                if (mailItem.EntityIsAvailable("BodyFormat"))
                    mailItem.BodyFormat = OlBodyFormat.olFormatPlain;
                mailItem.Body = "NetOffice C# Test06" + DateTime.Now.ToLongTimeString();
                mailItem.Subject = "Test06";
                mailItem.Display();
                mailItem.Close(OlInspectorClose.olDiscard);

                if(_closeEventCalled)
                    return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
                else
                    return new TestResult(false, DateTime.Now.Subtract(startTime), "CloseEvent not triggered.", null, "");
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
                NetOffice.OutlookSecurity.Supress.Enabled = false;
            }
        }
Beispiel #16
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            try
            {
                Outlook.Application application = null;

                object nativeProxy = System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application");
                application = new Outlook.Application(null, nativeProxy);

                textBoxLog.Clear();
                textBoxLog.AppendText("we got running outlook instance\r\n");
                textBoxLog.AppendText("outlook version is " + application.Version);

                // instance was already running at start. we dispose references but not quit application
                application.Dispose();
            }
            catch (System.Runtime.InteropServices.COMException exception)
            {
                _hostApplication.ShowErrorDialog(null, exception);
            }            
        }
Beispiel #17
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook
            Outlook.Application outlookApplication = new Outlook.Application();

            // create MailItem and register close event
            Outlook.MailItem mailItem = outlookApplication.CreateItem(OlItemType.olMailItem) as Outlook.MailItem;
            mailItem.CloseEvent += new NetOffice.OutlookApi.MailItem_CloseEventHandler(mailItem_CloseEvent);

            // BodyFormat is not available in Outlook 2000, we check at runtime the property is available
            if (mailItem.EntityIsAvailable("BodyFormat"))
                mailItem.BodyFormat = OlBodyFormat.olFormatPlain;
            mailItem.Body = "ExampleBody";
            mailItem.Subject = "ExampleSubject";
            mailItem.Display();
            mailItem.Close(OlInspectorClose.olDiscard);

            // close outlook and dispose
            outlookApplication.Quit();
            outlookApplication.Dispose();
        }
Beispiel #18
0
        public void RunExample()
        {
            // start outlook
            Outlook.Application outlookApplication = new Outlook.Application();

            // create a new TaskItem.
            Outlook.TaskItem newTask = outlookApplication.CreateItem(OlItemType.olTaskItem) as Outlook.TaskItem;

            // Configure the task at hand and save it.
            newTask.Subject = "Don't forget to check for NetOffice.DeveloperToolbox updates";
            newTask.Body = "check updates here: http://netoffice.codeplex.com/releases";
            newTask.DueDate = DateTime.Now;
            newTask.Importance = OlImportance.olImportanceHigh;
            newTask.Save();

            // close outlook and dispose
            outlookApplication.Quit();
            outlookApplication.Dispose();

            _hostApplication.ShowFinishDialog("Done!", null);
        }
Beispiel #19
0
        public void RunExample()
        {
            // start outlook
            Outlook.Application outlookApplication = new Outlook.Application();

            // SendAndReceive is supported from Outlook 2007 or higher
            // we check at runtime the feature is available
            if (outlookApplication.Session.EntityIsAvailable("SendAndReceive"))
            {
                // one simple call
                outlookApplication.Session.SendAndReceive(false);
            }
            else
            {
                _hostApplication.ShowErrorDialog("This version of MS-Outlook doesnt support SendAndReceive.", null);
            }

            // close outlook and dispose
            outlookApplication.Quit();
            outlookApplication.Dispose();

		 _hostApplication.ShowFinishDialog("Done!", null);
        }
Beispiel #20
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook
            Outlook.Application outlookApplication = new Outlook.Application();

            // enum contacts 
            int i = 0;
            Outlook.MAPIFolder contactFolder = outlookApplication.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
            foreach (COMObject item in contactFolder.Items)
            {
                Outlook.ContactItem contact = item as Outlook.ContactItem;
                if (null != contact)
                {
                    i++;
                    ListViewItem listItem = listViewContacts.Items.Add(i.ToString());
                    listItem.SubItems.Add(contact.CompanyAndFullName);
                }
            }

            // close outlook and dispose
            outlookApplication.Quit();
            outlookApplication.Dispose();
        }
Beispiel #21
0
        private void buttonStartExample_Click(object sender, EventArgs e)
        {
            // start outlook
            _outlookApplication = new Outlook.Application();

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

            Outlook._NameSpace outlookNS = _outlookApplication.GetNamespace("MAPI");
            Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
            inboxFolder.Display();

            // add a commandbar popup
            Office.CommandBarPopup commandBarPopup = (Office.CommandBarPopup)_outlookApplication.ActiveExplorer().CommandBars["Menu Bar"].Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarPopup.Caption = "commandBarPopup";

            #region few words, how to access the picture
            /*
             you can see we use an own icon via .PasteFace()
             is not possible from outside process boundaries to use the PictureProperty directly
             the reason for is IPictureDisp: http://support.microsoft.com/kb/286460/de
             its not important is early or late binding or managed or unmanaged, the behaviour is always the same
             For example, a COMAddin running as InProcServer and can access the Picture Property
            */
            #endregion

            #region CommandBarButton

            // add a button to the popup
            commandBarBtn = (Office.CommandBarButton)commandBarPopup.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption;
            commandBarBtn.Caption = "commandBarButton";
            Clipboard.SetDataObject(HostApplication.DisplayIcon.ToBitmap());
            commandBarBtn.PasteFace();
            commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

            #endregion

            #region Create a new toolbar

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

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

            // add a dropdown box to the toolbar
            commandBarPopup = (Office.CommandBarPopup)commandBar.Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarPopup.Caption = "commandBarPopup";

            // add a button to the popup, we use an own icon for the button
            commandBarBtn = (Office.CommandBarButton)commandBarPopup.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
            commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption;
            commandBarBtn.Caption = "commandBarButton";
            Clipboard.SetDataObject(HostApplication.DisplayIcon.ToBitmap());
            commandBarBtn.PasteFace();
            commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

            #endregion

            // set buttons
            buttonStartExample.Enabled = false;
            buttonQuitExample.Enabled = true;
        }
Beispiel #22
0
        public void ClickEmail()
        {
            try
            {
                var type = Data.ProviderCollection.GetType(this.Provider, this.Type);
                if (type == null) return;
                string mails = type.Email;
                if (string.IsNullOrEmpty(mails)) return;
                if (!mails.Contains("@"))
                { MessageBox.Show(mails.ToString(), "მისამართი", MessageBoxButtons.OK, MessageBoxIcon.Information); return; }
                string[] mailsarray = mails.Split(';');
                string subject = "თანხის " + this.Type + " " + this.From + " (INC" + this.Inc + ")";

                using (Outlook.Application app = new Outlook.Application())
                {
                    var mail = (Outlook.MailItem)app.CreateItem(Outlook.Enums.OlItemType.olMailItem);
                    var mailIndex = mails.IndexOf(";");
                    if (mailIndex == -1)
                        mail.To = mails;
                    else
                    {
                        mail.To = mails.Substring(0, mailIndex + 1);
                        mail.CC += mails.Substring(mailIndex);
                    }
                    mail.CC += ";" + GetEMails();
                    mail.Subject = subject;
                    mail.HTMLBody = File.ReadAllText(Path.Combine(Application.StartupPath, "conf\\OutlookBody.html")) + mail.HTMLBody;
                    string scanpath = GetScanImgPath();
                    if (File.Exists(scanpath))
                        mail.Attachments.Add(scanpath);
                    mail.Display();
                }
            }
            catch (Exception ex)
            {
                ErrorBox.Show(ex.Message, ex.StackTrace);
            }
        }
 public OutlookToolkitApi()
 {
     app = new Outlook.Application();
     ns = app.GetNamespace("MAPI");
 }
Beispiel #24
0
 private void CreateOfficeApplication()
 {
     switch (_officeApp)
     {
         case "Excel":
             _excelApplication = new Excel.Application("Excel.Application");
             break;
         case "Word":
             _wordApplication = new Word.Application("Word.Application");
             break;
         case "Outlook":
             _outlookApplication = new Outlook.Application("Outlook.Application");
             break;
         case "Power Point":
             _powerpointApplication = new PowerPoint.Application("PowerPoint.Application");
             break;
         case "Access":
             _accessApplication = new Access.Application("Access.Application");
             break;
         case "Project":
             _projectApplication = new Project.Application("MSProject.Application");
             break;
         case "Visio":
             _visioApplication = new Visio.Application("Visio.Application");
             break;
         default:
             throw new ArgumentOutOfRangeException("officeApp");
     }
 }
Beispiel #25
0
        public TestResult DoTest()
        {
            Outlook.Application application = null;
            DateTime startTime = DateTime.Now;
            try
            {
                Bitmap iconBitmap = new Bitmap(System.Reflection.Assembly.GetAssembly(this.GetType()).GetManifestResourceStream("OutlookTestsCSharp.Test07.bmp"));

                // start outlook
                application = new Outlook.Application();
                NetOffice.OutlookSecurity.Supress.Enabled = true;

                Office.CommandBar commandBar;
                Office.CommandBarButton commandBarBtn;

                Outlook._NameSpace outlookNS = application.GetNamespace("MAPI");
                Outlook.MAPIFolder inboxFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
                inboxFolder.Display();

                // add a commandbar popup
                Office.CommandBarPopup commandBarPopup = (Office.CommandBarPopup)application.ActiveExplorer().CommandBars["Menu Bar"].Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarPopup.Caption = "commandBarPopup";
  
                #region CommandBarButton

                // add a button to the popup
                commandBarBtn = (Office.CommandBarButton)commandBarPopup.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption;
                commandBarBtn.Caption = "commandBarButton";
                Clipboard.SetDataObject(iconBitmap);
                commandBarBtn.PasteFace();
                commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

                #endregion

                #region Create a new toolbar

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

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

                // add a dropdown box to the toolbar
                commandBarPopup = (Office.CommandBarPopup)commandBar.Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarPopup.Caption = "commandBarPopup";

                // add a button to the popup, we use an own icon for the button
                commandBarBtn = (Office.CommandBarButton)commandBarPopup.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarBtn.Style = MsoButtonStyle.msoButtonIconAndCaption;
                commandBarBtn.Caption = "commandBarButton";
                Clipboard.SetDataObject(iconBitmap);
                commandBarBtn.PasteFace();
                commandBarBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(commandBarBtn_Click);

                #endregion
              
                return new TestResult(true, DateTime.Now.Subtract(startTime), "", null, "");
            }
            catch (Exception exception)
            {
                return new TestResult(false, DateTime.Now.Subtract(startTime), exception.Message, exception, "");
            }
            finally
            {
                if (null != application)
                {
                    application.Quit();
                    application.Dispose();
                }
                NetOffice.OutlookSecurity.Supress.Enabled = false;
            }
        }