none
Getting/Creating an Outlook Application in Windows 7 / Vista RRS feed

  • Question

  • Hi,

     I want to get an object representing Outlook 2010. 


     _app = new Microsoft.Office.Interop.Outlook.Application();

     If outlook is not working my code is working as expected but if Outlook 2010 is already running, it's raised an COM exception error.

     If i use 

    System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("OUTLOOK");
    int collCount = processes.Length;
    if (collCount != 0)
    {
    // Outlook already running, hook into the Outlook instance
    _app = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
    }
    if (_app == null)
    {
    // Outlook not already running, start it
    _app = new Microsoft.Office.Interop.Outlook.Application();
    }

    It raised below error

    Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE)) 

    This code on Windows XP machine with Outlook 2010 working fine.

    can any one has idea how can i solve that ? 

    I am using VS 2010(C#) , Windows 7 (32bit)

    Any help would be appreciated.

    Thanks & Regards,

    MohammadAzhar

    Monday, July 16, 2012 10:26 AM

Answers

  • so by design - it will not work. Windows explicitly rejects any communication between such processes.

    • Marked as answer by MohammadAzhar Monday, July 16, 2012 11:20 AM
    Monday, July 16, 2012 11:15 AM

All replies

  • Hi,

     I want to get an object representing Outlook 2010. 


     _app = new Microsoft.Office.Interop.Outlook.Application();

     If outlook is not working my code is working as expected but if Outlook 2010 is already running, it's raised an COM exception error.

     If i use 

    System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("OUTLOOK");
    int collCount = processes.Length;
    if (collCount != 0)
    {
    // Outlook already running, hook into the Outlook instance
    _app = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
    }
    if (_app == null)
    {
    // Outlook not already running, start it
    _app = new Microsoft.Office.Interop.Outlook.Application();
    }

    It raised below error

    Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE)) 

    This code on Windows XP machine with Outlook 2010 working fine.

    can any one has idea how can i solve that ? 

    I am using VS 2010(C#) , Windows 7 (32bit)

    Any help would be appreciated.

    Thanks & Regards,

    MohammadAzhar

    Monday, July 16, 2012 10:26 AM
  • is your app and outlook running in the same security context? for example, did you start your outlook or app using elevated priviliges and the other one not? (run as administrator)
    Monday, July 16, 2012 10:42 AM
  • Thank you for your quick response.

    My application is running as administrator and outlook is with normal user rights.

    Monday, July 16, 2012 11:00 AM
  • so by design - it will not work. Windows explicitly rejects any communication between such processes.

    • Marked as answer by MohammadAzhar Monday, July 16, 2012 11:20 AM
    Monday, July 16, 2012 11:15 AM
  • thank you for your reply.
    Monday, July 16, 2012 11:21 AM