Getting COMException while accessing email in Outlook 2010

Hello, I am trying to access my messages in Outlook 2010 using a C # console application.

Visual Studio starts with administrator privileges, and I added a link to Microsoft.Office.Interop.Outlook v14.0.0.0 and used it as Outlook.

My code is:

 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 displays 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?

+4
source share
3 answers

Try reading 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 working heap for the new user. Therefore, the process does not start.

Workaround: To work around this problem, change the value of the following registry key: HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Control \ Session Manager \ Subsystems \ Windows

+5
source

This is due to process privileges. Please run Visual Studio and Outlook as an administrator.

A simple solution. Run as administrator, or run both as normal privilege level.

Relationship Ramez Ali

+6
source

The 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 = databasesrv, 1 ServerDll = winsrv: UserServerDllInitialization, 3 ServerDll = winsrv: ConServerDllInitialization, 2 ProfileControl MaxRequestThreads = 16

ASP.net user must be activated in 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 provide write permissions.

in web.config change impersonate = true,

in IIS for Windows Server 2003, select the account as NETWORK SERVICE.

In DCOMCONFIG, change the identifier as an interactive user.

Also, for a particular directory, all rights are indicated.


Internet Options - Advanced tab. Scroll to the end and uncheck "Verify certificate for publisher."

Registry: CLSID: {0006F03A-0000-0000-C000-000000000046} Under this key in HKEY_CLASSES_ROOT \ CLSID \ add the string value AppID = the same value as the identifiers For example: {0006F03A-0000-0000-C000-000000000046}

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

Right-click on CLSID and APPID, Permission, Security, and edit startup and access permissions to add and provide network permissions and interactive full permissions.


Disable all other Outlook add-ins: Outlook Tools menu | Options | Other tabs | Additional options | COM add-ins | uncheck the boxes. If this solves the problem, then re-enable one add-in until the problem appears.


provides read / write access to the IIS user for the folder "C: \ WINDOWS \ TEMP" All Dlls must be located on C: \ Program Files \ Microsoft Visual Studio 9.0 \ Visual Studio Tools for Office \ PIA \ Office12

0
source

All Articles