Outlook Interop例外-显示新的mailitem [英] Outlook Interop exception - displaying new mailitem

查看:148
本文介绍了Outlook Interop例外-显示新的mailitem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试通过Outlook自动生成电子邮件-

Trying to automatically generate a mail message via Outlook -

添加了对Microsoft.Office.Interop.Outlook 14.0.0.0的引用

Added a reference to Microsoft.Office.Interop.Outlook 14.0.0.0

它可在Win 8/Office 2013 PC上运行,但在Windows 7/Office 2010上会发生以下异常而失败.

It works on a Win 8/Office 2013 PC, but fails with the following exception on Win 7/Office 2010.

代码:

Application outlookApp = new Application();
MailItem message = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);
message.Subject = "subject";
message.Display(message);
message.HTMLBody = "body" + message.HTMLBody; //to get default signature

例外是:

无法将类型为'System .__ ComObject'的COM对象转换为接口 键入"Microsoft.Office.Interop.Outlook.Application".这 操作失败,因为COM上的QueryInterface调用 具有IID的接口的组件 "{00063001-0000-0000-C000-000000000046}"由于以下原因而失败 错误:未注册图书馆. (来自HRESULT的异常:0x8002801D (TYPE_E_LIBNOTapped)).

Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063001-0000-0000-C000-000000000046}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

推荐答案

解决方案最终是:

http://www.fieldstonsoftware.com/support/support_gsyncit_2013.shtml

Lync 2013安装在Office 2010的顶部.这会将注册表项添加到HKCR \ TypeLib {00062FFF-0000-0000-C000-000000000046}.

Lync 2013 was installed on top of Office 2010. This adds a registry entry to HKCR\TypeLib{00062FFF-0000-0000-C000-000000000046}.

该注册表项的子项将是编号不同的文件夹,指示已安装的Office的版本号. (在这种情况下,9.4表示2010,9.5表示2013).一旦删除了与Outlook版本不一致的版本号,便可以解决.

Subkey to that registry entry will be different numbered folders, indicating version numbers of Office installed. (9.4 in this case, indicates 2010, 9.5 indicates 2013). Once the version number not consistent with the version of Outlook was deleted, it was resolved.

这篇关于Outlook Interop例外-显示新的mailitem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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