Failure creating an Outlook application object on Vista

While creating a Outlook application object from another process in C# like:

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

or powershell

PS> $outlook = new-object -com Outlook.Application

or straight up COM via CoCreateInstance on Vista it's possible to receive the following error:

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005

Error 0x80080005 (CO_E_SERVER_EXEC_FAILURE) is sort of a generic COM error message that occurs for many reasons while calling CoCreateInstance. One reason someone could receive this error is because the client process and the server process (outlook.exe in this case) are running at different integrity levels. By default it doesn't appear that COM likes talking across two different processes that are running at different integrity levels. There supposedly is a way to implement the COM server in such a way to support it but currently the Outlook COM server doesn't support it.

People who develop their applications on Vista using Visual Studio, which runs at integrity level high by default, will run into this issue often when Outlook is already running. By default Outlook runs at integrity level medium and if the client application is run from Visual Studio it will inherit the high integrity level and thus there will be an integrity level mismatch.

To fix this one needs to make the integrity levels match so either start the client application outside Visual Studio at the normal medium integrity level or run Outlook at the high integrity level (i.e. as Administrator). However it is not recommended to run Outlook at integrity level high all the time. Another way to deal with this is to ensure Outlook is not already running so COM will start the process at the correct integrity level of the client process that created the application object.

I don't know of any way to detect this exact situation programmatically but process explorer works well for manually checking the integrity levels of processes.

5 Comments

  • This caused me to scream and curse for several hours when I migrated somes clients from XP Pro/O2003 to Vista Business/O2007.

    My (HACKISH) solution was to launch Outlook as Administrator, but its nice to have more information.

    I'll look into running both Outlook and the .Net application at Medium Integrity level I guess.

  • It seems that this problem only repro in OS running Vista x64. Vista x86 does not run into this problem. Has anyone found this oddity as well?

  • Hi Wes,
    I want to open address book in a winform application. I am able to retrieve contacts and populate them in a listview but i need to retrieve the contacts from the Address book.How can I achive this?
    Any help on this will be greatly appreciated.

    Thanks and regards,
    Vicky
    vivek.minhas@catalytic.com

  • Vicky have a look at the AddressLists that appear on the Namespace object.

  • hello,
    anybody sollution? the bellow code is not working in vista

    objOutlk = new ActiveXObject("Outlook.Application")

    In XP the above javascript code works fine to open outlook in web page to open as client side , but it doesnt work in vista! can anyone help?

    Many thanks

Comments have been disabled for this content.