Getting COMException when accessing Emails on Outlook 2010
Asked Answered
C

3

5

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:

Console.Write("starting");
Outlook.Application app = new Outlook.Application();
Outlook.NameSpace mapiNameSpace = app.GetNamespace("MAPI");
Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Console.WriteLine(((Outlook.MailItem)myInbox.Items[0]).Subject);
Console.WriteLine("readline:");
Console.ReadLine();

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?

Chyle answered 11/2, 2013 at 9:29 Comment(4)
Try to read the following: support.microsoft.com/kb/870655Tropophilous
I am still getting the same error. Should I reboot after I have changed the registry key?Chyle
I can create now a new Outlook Application, if a Outlook Instance isn't running. I started Visual Studio without admin rights.Chyle
Yes I can create a Outlook instance now, maybe it was the registry key which affected the exception.Chyle
T
5

Try to read the following: http://support.microsoft.com/kb/870655

Cause:
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.

WORKAROUND: To work around this problem, modify the value of the following registry subkey: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows

Tropophilous answered 11/2, 2013 at 13:15 Comment(3)
Very helpful answer. Could you add the relevant change to the registry key in case the link breaks?Brinkema
I had a related situation. I confirm that running visual studio (or the app) AND outlook with the same permission model (both admin or both normal) fixes this problem. However I have not tested the workaround in the registry. (Tested with Outlook 2016)Blackbeard
The article says to add 512 but my has set 768: ObjectDirectory=\Windows SharedSection=1024,20480,768. And I have noticed that the ServerDll is set as sxssrv: ServerDll=sxssrv. I presume that is the default configuration in registry since I did not change it. I am wondering what is 512 anyway?Hebe
A
7

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.

Regards Rameez Ali

Acrolein answered 7/2, 2014 at 7:27 Comment(1)
This is way better than monkeying with the registry.Zeidman
T
5

Try to read the following: http://support.microsoft.com/kb/870655

Cause:
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.

WORKAROUND: To work around this problem, modify the value of the following registry subkey: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows

Tropophilous answered 11/2, 2013 at 13:15 Comment(3)
Very helpful answer. Could you add the relevant change to the registry key in case the link breaks?Brinkema
I had a related situation. I confirm that running visual studio (or the app) AND outlook with the same permission model (both admin or both normal) fixes this problem. However I have not tested the workaround in the registry. (Tested with Outlook 2016)Blackbeard
The article says to add 512 but my has set 768: ObjectDirectory=\Windows SharedSection=1024,20480,768. And I have noticed that the ServerDll is set as sxssrv: ServerDll=sxssrv. I presume that is the default configuration in registry since I did not change it. I am wondering what is 512 anyway?Hebe
D
0

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

ASP.net 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."

Registry: 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

Duntson answered 10/2, 2014 at 6:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.