Getting COMException when accessing Emails on Outlook 2010


Getting COMException when accessing Emails on Outlook 2010

Hello I am trying to access my emails in Outlook 2010 via a C# Console Application.
Visual Studio is started with admin rights and I have added a reference to Microsoft.Office.Interop.Outlook v14.0.0.0 and used it as Outlook.
My Code:
Outlook.Application app = new Outlook.Application();
Outlook.NameSpace mapiNameSpace = app.GetNamespace(“MAPI”);
Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

The second line, throws an error message:
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).

Do you know any solutions?


Solution 1:

Try to read the following:

If many COM+ applications run under different user accounts
that are specified in the This User property, the computer cannot
allocate memory to create a new desktop heap for the new user.
Therefore, the process cannot start.

To work around this problem, modify the value of the
following registry subkey:

Solution 2:

It is because of privileges of the process.Please run Visual studio and outlook as administrator.

Simple solution. Run both as administrator or run both as normal privilege level.

Rameez Ali

Solution 3:

Following Steps may be helpful…

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems – Windows

%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16 user must be excist on Admin Tools/Computer Management/User

For 32-bit (x86), create this folder:
C:\Windows\System32\config\systemprofile\Desktop–> add Network Services

Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files give write permissions.

in Web.config
change impersonate= true,

in IIS for windows server 2003 select the account as NETWORK SERVICE.

In DCOMCONFIG change identity as The interactive User.

Also for the particular directory give all the rights.

Internet Options – Advanced tab. Scroll all the way to the bottom and uncheck item called “Check for Publisher’s certificate revocation.”

CLSID: {0006F03A-0000-0000-C000-000000000046}
Under this key in HKEY_CLASSES_ROOT\CLSID\, add a string value AppID = same value as the IDs Eg:{0006F03A-0000-0000-C000-000000000046}

Then under HKEY_CLASSES_ROOT\AppID\ add a string value: RunAs = Interactive User

Right click on CLSID & APPID, Permission, Security, and edit both the launch & access permissions to add and give Network Service and Interactive full permissions.

Disable all other Outlook add-ins: Outlook Tools menu | Options | Other tab | Advanced Options | COM Add-Ins | uncheck the items. If this solves the problem, then re-enable one add-in at a time until the problem reappears

give read/write access to IIS user for folder “C:\WINDOWS\TEMP”
All Dll should be placed on C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12