向Outlook添加新项时的ComException [英] ComException while add new Item to Outlook

查看:120
本文介绍了向Outlook添加新项时的ComException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是


我正在开发VSTO的Outlook 2007/2010插件(2007年的项目,但也适用于2010年)。此应用程序使用证书(System.Security.Cryptography.X509Certificates.X509Certificate类),它们在初始化
(在其他线程中)后处理一段时间 - 我怀疑它的原因。


过了一会儿,当我试图创建新的outlook对象(mail / note / task ...)时,我得到了ComException(有时代码为HRESULT:0x800401E3)(MK_E_UNAVAILABLE))



 outlookApp = new Microsoft.Office.Interop.Outlook.Application(); 
var note =(Microsoft.Office.Interop.Outlook.NoteItem)outlookApp .CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olNoteItem);




当我试图通过其他方式获取Outlook时发生同样的异常(例如,马歇尔或CreateObject("Outlook.Application"))。请注意,应用程序启动后,一切正常,所以有什么问题?如果它是带有证书的东西,是否有
a方式通过其他方式向Outlook添加对象,避免此错误?

$
非常感谢

解决方案

此语句不属于Outlook加载项:


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


而是使用添加公开的Outlook.Application对象 - 在建筑中,例如Globals.ThisAddin.Application。


Hello,

i'm developing a Outlook 2007/2010 plugin in VSTO (project for 2007, but works also with 2010). This application works with certificates (System.Security.Cryptography.X509Certificates.X509Certificate class), which are handling some time after initialization (in other threads) - i suspect its the reason.

After a while, when im trying to create new outlook object (mail/note/task...) i get ComException (sometime with code HRESULT: 0x800401E3 )(MK_E_UNAVAILABLE))

outlookApp = new Microsoft.Office.Interop.Outlook.Application();
var note = (Microsoft.Office.Interop.Outlook.NoteItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olNoteItem);


The same exception happens when i'm trying to get outlook by other ways (e.g. marshall or CreateObject("Outlook.Application")). Note that immediately after application start everything works fine, so what's wrong? If it is something with certicifates, is there a way to add an object to outlook by other way, avoiding this error?

Thanks a lot

解决方案

This statement doesn't belong in an Outlook add-in:

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

Instead, use the Outlook.Application object exposed by the add-in architecture, e.g. Globals.ThisAddin.Application.


这篇关于向Outlook添加新项时的ComException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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