问题
Hi I am having similar issue
CreateObject on Outlook.Application fails on Outlook 2010 when Outlook is running under a different account
but want customized solution.
I want to sent email with attachment for which my code works but if OutLook app is already opened as desktop app, then I am getting this error.
Requirement: I want to open outlook window showing everything like when we compose message in window.
I am doing this:
Microsoft.Office.Interop.Outlook.Application outlookApp = new Outlook.Application();
Getting this error if OutLook app is running.
Error sending a report: System.Runtime.InteropServices.COMException (0x80080005): 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)).
at ReportViewerControl.SendOutLookMail_Click(Object sender, EventArgs e) in c:\Projects\MSCatalog\MS SQLSERVER\Web\UserControls\Reports\ReportViewerControl.ascx.cs:line 262
When I close OutLook no error and everything works like I want. I dont want to close OutLook pro grammatically as other solutions suggested here
Just 1 more thing to mention that I am using Microsoft.Office.Interop.Outlook.dll is this 32bit/64bit problem? Or have to use some other new Dll?
回答1:
The error is CO_E_SERVER_EXEC_FAILURE. Most likely this happens if the security context of your app and Outlook are different. Is either app running with elevated privileges (Run As Administrator)?
回答2:
Finally I found my answer. I tested and its working.
- In start menu select Run
- Type dcomcnfg and click OK
- Component Services window is opened.
- Expand the nodes Component Services -> MyComputer -> DCOM Config .
- Right click on the application (Outlook Message Attachment) and select properties.
- Click on Identity tab whatever necessary.
- Click on “The interactive user" then OK
Found it here
Click Here
来源:https://stackoverflow.com/questions/42979705/new-outlook-application-thorws-error-if-outlook-app-is-running