8/7/2023 0 Comments .eml to msg converterWorking code: mapi.MAPIInitialize((mapi.MAPI_INIT_VERSION, mapi.MAPI_MULTITHREAD_NOTIFICATIONS)) So it started to work after I have moved from Outlook x86 to 圆4, and I added the following registry keys: Files\\Microsoft Files\\Microsoft are copies of the keys that you can find in: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Classes\CLSID Set Msg = Session.CreateMessageFromMsgFile("c:\temp\test.msg") If using Redemption is an option (I am also its author), it allows to convert an EML file to MSG without using Outlook converter as easily as (in VB script): set Session = CreateObject("Redemption.RDOSession") Also, your code never checks that IConverterSession::MIMEToMAPI returns a success return code. your code is a COM/VSTO addin or Outlook VBA). Perhaps most importantly, as of Outlook 2016, IConverterSession interface only works if your code is running inside the outlook.exe address space (i.e. Secondly, try to open the MSG file in a utility like SSView (it shows the data on the IStorage level) or OutlookSpy (I am its author - click OpenIMsgOnIStg button) - it will show the MSG file data on the MAPI level. Msg = mapi.OpenIMsgOnIStg(0, None, stg, None, 0, mapi.MAPI_UNICODE)Ĭs.MIMEToMAPI(eml, msg, _SMTP | _INCLUDE_BCC)įirstly, sizes don't matter, especially if you compare different file formats. Storagecon.STGM_CREATE | storagecon.STGM_READWRITE | storagecon.STGM_TRANSACTED) Stg = pythoncom.StgCreateDocfile(r"C:\test.msg", MyFactory = pythoncom.ObjectFromAddress(com_classfactory.value, pythoncom.IID_IClassFactory)Ĭs = MyFactory.CreateInstance (None, str(mapi.IID_IConverterSession))Įml = mapi.OpenStreamOnFileW(r"C:\test.eml") IconvOLE.DllGetClassObject(clsid_class, iclassfactory, ref(com_classfactory)) Iclassfactory = uuid.UUID(str(pythoncom.IID_IClassFactory)).bytes_le IconvOLE = ctypes.OleDLL(r'C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLMIME.DLL')Ĭlsid_class = uuid.UUID(str(mapi.CLSID_IConverterSession)).bytes_le Mapi.MAPIInitialize((mapi.MAPI_INIT_VERSION, mapi.MAPI_MULTITHREAD_NOTIFICATIONS)) I'm a little bit lost, any ideas? from win32com.mapi import mapi It creates a msg file but the file is unreadable by Outlook and the size is two times bigger than the input eml file. Using various examples I was able to gather this code, but well, it doesn't work. I'm trying to convert EML file to MSG (Outlook) file using python.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |