如果Outlook应用程序正在运行,则会出现新的Outlook.Application()thorws错误

时间:2017-03-23 14:57:29

标签: email outlook com

您好我有类似的问题

CreateObject on Outlook.Application fails on Outlook 2010 when Outlook is running under a different account

但想要定制解决方案。

我想发送带有我的代码可用的附件的电子邮件但是如果OutLook应用程序已经作为桌面应用程序打开,那么我收到此错误。

要求:我想打开Outlook窗口,显示我们在窗口中撰写邮件时的所有内容。

我这样做:

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

如果OutLook应用程序正在运行,则会出现此错误。

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

当我关闭OutLook没有错误,一切都像我想要的那样。我不想像其他解决方案那样在语法上关闭OutLook

还有一件事要提到我正在使用 Microsoft.Office.Interop.Outlook.dll  这是32位/ 64位的问题吗?或者必须使用其他一些新的Dll?

2 个答案:

答案 0 :(得分:2)

错误是CO_E_SERVER_EXEC_FAILURE。如果您的应用和Outlook的安全上下文不同,则很可能会发生这种情况。应用程序是否以提升的权限运行(以管理员身份运行)?

答案 1 :(得分:0)

最后我找到了答案。我测试了它的工作。

  1. 在开始菜单中选择运行
  2. 键入dcomcnfg并单击“确定”
  3. 打开“组件服务”窗口。
  4. 展开节点组件服务 - > MyComputer - > DCOM配置。
  5. 右键单击应用程序(Outlook邮件附件)并选择属性。
  6. 根据需要点击“身份”标签。
  7. 点击“互动用户”,然后点击确定
  8. 在这里找到它

    Click Here

相关问题