none
Outlook 2010 Application Startup Event does not get triggered RRS feed

  • Question

  • Hello!

    I have some code where i am trying to use a ConsoleApplication to launch outloook. I am trying to measure how long outlook takes to load. For this, i am trying to use the Application Startup Event to trigger a method where i can stop a timer, also i am trying to do this without creating a Add-in. I can get the MAPILogonComplete event to work, but i cannot get the Startup event to work. I've tried defining the event three different ways, and none of them work.

    Below is the code that i am trying to use.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Outlook = Microsoft.Office.Interop.Outlook;
    using System.Windows.Forms;
    using Office = Microsoft.Office.Core;
    using Word = Microsoft.Office.Interop.Word;
    using System.IO;
    using Shell32;
    using System.Threading;
    
    namespace ConsoleApplication
    {
        class Program
        {
    
            static void Main(string[] args)
            {
                Outlook.NameSpace myOutlookNS = null;
                Outlook.MAPIFolder myOutlookInbox = null;
                Outlook.Application myOutlookApp = null;
                Outlook._Explorer myOutlookExp = null;
                myOutlookApp = new Outlook.Application();
                ((Microsoft.Office.Interop.Outlook.ApplicationEvents_11_Event)myOutlookApp).Startup += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_StartupEventHandler(Application_Startup);
                ((Outlook.Application)myOutlookApp).Startup += new Outlook.ApplicationEvents_11_StartupEventHandler(Application_Startup);
                myOutlookApp.Startup += new Outlook.ApplicationEvents_11_StartupEventHandler(Application_Startup);
                myOutlookApp.MAPILogonComplete += new Outlook.ApplicationEvents_11_MAPILogonCompleteEventHandler(Application_MAPILogonComplete);            
                myOutlookNS = myOutlookApp.GetNamespace("MAPI");
                myOutlookInbox = myOutlookNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
                myOutlookExp = myOutlookApp.Explorers.Add(myOutlookInbox, Outlook.OlFolderDisplayMode.olFolderDisplayNormal);
                Thread.Sleep(30000);
            }
    
            static void Application_MAPILogonComplete()
            {
                MessageBox.Show("MAPILogonComplete");
            }
    
            static void Application_Startup()
            {
                MessageBox.Show("Outlook Startup Event");
            }
    
        }
    }

    Thanks.

    Thursday, September 20, 2012 6:33 PM

Answers

  • Hi lesantian,

    Thanks for posting in the MSDN Forum.

    It's based on my experience that Startup event must be fired after all add-in has been loaded. I think when you start Outlook process in console there has something to notified the Outlook that all add-in has been loaded. So the Startup event will not fired. Here seems that has no work round for it. And I think it can't be used to measure whether Outlook begin to start. If you want to measure the time of Outlook's launch I suggest you begin form the Outlook application instance has been created to MAPILogon has been finished.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, September 24, 2012 4:56 AM
    Moderator

All replies

  • Hi lesantian,

    Thanks for posting in the MSDN Forum.

    It's based on my experience that Startup event must be fired after all add-in has been loaded. I think when you start Outlook process in console there has something to notified the Outlook that all add-in has been loaded. So the Startup event will not fired. Here seems that has no work round for it. And I think it can't be used to measure whether Outlook begin to start. If you want to measure the time of Outlook's launch I suggest you begin form the Outlook application instance has been created to MAPILogon has been finished.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, September 24, 2012 4:56 AM
    Moderator
  • Hi lesantia,

    Any update?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 27, 2012 6:30 AM
    Moderator