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).
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/).
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).
My code is :
Type converter = Type.GetTypeFromCLSID(MAPIMethods.CLSID_IConverterSession, true);
object obj = Activator.CreateInstance(converter);
MAPIMethods.IConverterSession session = (MAPIMethods.IConverterSession)obj;
The error is raised on "object obj = Activator.CreateInstance(converter);"
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.
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?
"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.
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
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.
User contributions licensed under CC BY-SA 3.0