如果Outlook应用程序正在运行,则新的Outlook.Application()会引发错误 [英] new Outlook.Application() thorws error if Outlook app is running
问题描述
我遇到类似的问题
在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?
最后,我找到了答案.我测试了它的工作原理.
- 在开始菜单中选择运行
- 键入dcomcnfg,然后单击确定"
- 组件服务"窗口打开.
- 展开节点Component Services-> MyComputer-> DCOM Config.
- 右键单击该应用程序(Outlook邮件附件),然后选择属性.
- 根据需要单击身份"选项卡.
- 单击交互式用户",然后单击确定
在这里找到
Hi I am having similar issue
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.
- 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
这篇关于如果Outlook应用程序正在运行,则新的Outlook.Application()会引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!