Вопрос

I have a number of Outlook MSGs that I need to save to alternate formats, such as MHT. The MSGs each have thousands of recipients, and I am aware that the MSG structure is not robust enough to handle large numbers of recipients. I believe that my first step is to import the MSGs into a PST, which can handle large numbers of recipients.

I am using Outlook 2010 and Redemption 5.4 (full). I am prepared to use either the Outlook object model or Redemption to accomplish my goals. Platform: Windows 7 SP1, 64-bit.

I have tried these methods:

//Establish Session
RDOSession rdoSession = new RDOSession();
rdoSession.Logon(null, null, false, true, null, true);

//Create empty mail item in PST.
RDOMail rdoMail = rdoSession.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Items.Add(null);

//Merge MSG into new, empty mail
//fi.FullName = C:\<subdirectories>\009.msg
rdoMail.Import(fi.FullName, rdoSaveAsType.olMSGUnicode);
rdoMail.Save();

//Save as MHT
rdoMail.SaveAs(diMht.FullName + @"\" + strNormalizedSubject + ".mht", Redemption.rdoSaveAsType.olMHTML);

This code fails to import the MSG into the PST. I receive this exception: {"Error importing: 0x8004011B"}

I have also tried this method, which does not rely on a PST.

RDOMail rdoMail = rdoSession.GetMessageFromMsgFile(fi.FullName, false);
string strNormalizedSubject = NormalizeSubject(rdoMail.Subject);

rdoMail.SaveAs(diMht.FullName + @"\" + strNormalizedSubject + ".mht", Redemption.rdoSaveAsType.olMHTML);

This code results in this exception: Error in OpenIMsgOnIStg: MAPI_E_CORRUPT_DATA.

I believe that Transend Migrator can convert MSGs with large numbers or recipients. However, that is not an option due to high licensing costs.

How can I save the MSG to another format?

Это было полезно?

Решение 2

Dmitry suggested that I treat MSG files as OLE storage files. That idea led me to this site: Reading an Outlook MSG File in C# CodeProject.

I have confirmed that the project is able to open MSGs with large numbers of recipients. I tested it with an MSG having 2,499 recipients.

That project may make it possible to extract the data required to build an MHT file.

Другие советы

0x8004011B is MAPI_E_CORRUPT_DATA. Looks like you have a corrupt PST store. Did you try to repair it using scanpst.exe?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top