如果Outlook应用程序正在运行,则新的Outlook.Application()会引发错误 [英] new Outlook.Application() thorws error if Outlook app is running

查看:796
本文介绍了如果Outlook应用程序正在运行,则新的Outlook.Application()会引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到类似的问题

在Outlook.Application上创建对象当Outlook在其他帐户下运行时,在Outlook 2010上失败

但需要定制的解决方案.

我想发送带有我的代码可以正常工作的附件的电子邮件,但是如果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

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

解决方案

最后,我找到了答案.我测试了它的工作原理.

  1. 在开始菜单中选择运行
  2. 键入dcomcnfg,然后单击确定"
  3. 组件服务"窗口打开.
  4. 展开节点Component Services-> MyComputer-> DCOM Config.
  5. 右键单击该应用程序(Outlook邮件附件),然后选择属性.
  6. 根据需要单击身份"选项卡.
  7. 单击交互式用户",然后单击确定

在这里找到

单击此处

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?

解决方案

Finally I found my answer. I tested and its working.

  1. In start menu select Run
  2. Type dcomcnfg and click OK
  3. Component Services window is opened.
  4. Expand the nodes Component Services -> MyComputer -> DCOM Config .
  5. Right click on the application (Outlook Message Attachment) and select properties.
  6. Click on Identity tab whatever necessary.
  7. Click on "The interactive user" then OK

Found it here

Click Here

这篇关于如果Outlook应用程序正在运行,则新的Outlook.Application()会引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆