Activator.CreateInstance上的MIME MAPI IConverterSession COMException [英] MIME MAPI IConverterSession COMException on Activator.CreateInstance

查看:142
本文介绍了Activator.CreateInstance上的MIME MAPI IConverterSession COMException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用IConverterSession从EML转换为MSG(从MIME转换为MAPI),但是我一直在遇到COM错误. 我使用C#MAPIMethods类包装IConverterSession(例如在此处找到的类:

I have been trying to use IConverterSession to convert from EML to MSG (MIME to MAPI), but I keep stumbling on COM errors. I use a C# MAPIMethods class to wrap IConverterSession (like the one found here : Save Mail in MIME format (*.eml) in Outlook Add-In).

首先,我遇到了未知clsid的问题,已通过这篇文章解决(

First, I had the problems of unknown clsid, solved with this post (https://blogs.msdn.microsoft.com/stephen_griffin/2014/04/21/outlook-2013-click-to-run-and-com-interfaces/).

现在已经编辑了正确的注册表项,我遇到了一个新问题:首先,我收到一条错误消息The operating system is not presently configured to run this application,并收到一个COMException:Retrieving the COM class factory for component with CLSID {4E3A7680-B77A-11D0-9DA5-00C04FD65685} failed due to the following error: 8007013d The system cannot find message text for message number 0x in the message file for . (Exception from HRESULT: 0x8007013D).

Now that the proper registry keys have been edited, I face a new problem: first, I get an error message The operating system is not presently configured to run this application, and I get a COMException: Retrieving the COM class factory for component with CLSID {4E3A7680-B77A-11D0-9DA5-00C04FD65685} failed due to the following error: 8007013d The system cannot find message text for message number 0x in the message file for . (Exception from HRESULT: 0x8007013D).

我的代码是:

    Type converter = Type.GetTypeFromCLSID(MAPIMethods.CLSID_IConverterSession, true); 
    object obj = Activator.CreateInstance(converter);
    MAPIMethods.IConverterSession session = (MAPIMethods.IConverterSession)obj;

在对象obj = Activator.CreateInstance(converter);"上引发错误.

The error is raised on "object obj = Activator.CreateInstance(converter);"

COMException通常表示类型是COM对象,但用于获取类型的类标识符无效,或者未注册所标识的类".因此,Type converter = Type.GetTypeFromCLSID(MAPIMethods.CLSID_IConverterSession, true);无法返回正确的类型,或者某个地方仍然缺少注册表项.

A COMException normally means that "type is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.". So either Type converter = Type.GetTypeFromCLSID(MAPIMethods.CLSID_IConverterSession, true); does not return the proper type, or there is still a registry key missing somewhere.

我在Win 64位上使用Office 15(2013)C2R 32位.该应用程序是在x86构建配置上设置的.

I am using Office 15 (2013) C2R 32 bits on Win 64bits. The application is setup on an x86 build configuration.

我在某处缺少什么吗?有人可以帮忙吗?

Is there something I am missing somewhere? Can anyone help?

推荐答案

当前未将操作系统配置为运行此应用程序"-听起来好像您的应用程序在32位版本的计算机上编译为x64前景.

"The operating system is not presently configured to run this application" - it sure sounds like your app is compiled as x64 on a machine with a 32 bit version of Outlook.

您是否尝试过使用兑换?它包装.c语言的IConverterSession.像下面这样的事情应该可以完成.

Have you tried to use Redemption? It wraps IConverterSession for .Net languages. Something like the following should do the job.

using Redemption;
...
Redemmption.RDOSession session = new Redemmption.RDOSession();
Redemmption.RDOMail msg = session.CreateMessageFromMsgFile(@"c:\temp\test.msg");
msg.Import(@"c:\temp\test.eml", Redemption.rdoSaveAsType.olRFC822);
msg.Save();

olRFC822格式将使用IConverterSession(如果可用),或者使用内部兑换转换器(如果IConverterSesison不可用)(例如,在Exchange版本的MAPI或无法使用IConverterSession的最新版本的Outlook 2016 C2R下). 如果您始终想强制使用Redemption或Outlook(IConverterSession)转换器,请使用olRFC822_Redemption或olRFC822_Outlook.

olRFC822 format will use IConverterSession if it is available or the internal Redemption converter if IConverterSesison is not available (e.g. under Exchange version of MAPI or the latest versions of Outlook 2016 C2R where IConverterSession cannot be used). Use olRFC822_Redemption or olRFC822_Outlook if you always want to force Redemption or Outlook (IConverterSession) converter.

这篇关于Activator.CreateInstance上的MIME MAPI IConverterSession COMException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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