0

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?

Jacob Quisenberry
  • 1,131
  • 3
  • 20
  • 48

2 Answers2

0

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

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • I believe the data being reported as corrupt is the MSG. The PST that I would like to import the MSG into is fine, and I can import other MSGs with no problem. The MSG has thousands of recipients, which makes Outlook unable to open it. I have two versions of 009.msg, one created with OutlookSpy and one created by dragging a message from a PST to my desktop. Both exhibit the same behavior. – Jacob Quisenberry Mar 22 '13 at 18:04
  • If you can re-create them, save them in the olMsgUnicode format instead of olMsg. – Dmitry Streblechenko Mar 23 '13 at 21:39
  • Attempting to recreate the MSG from the PST source using olMsgUnicode results in this OutlookSpy Script Error: `There is not enough free memory to run this program. Quit one or more programs, and then try again.` In general, I am not able to specify the format of the source MSGs. I get MSGs from many clients, who may use a variety of systems. I still believe that the issue is the large number of recipients. – Jacob Quisenberry Mar 25 '13 at 20:59
  • 1
    If you cannot recreate the MSG files, I don't think there is anything you can do - neither Outlook not Redemption (which uses the same API) cannot open them. You can of course parse the MSG formatted files explicitly, but the error comes from the COM system, not event MAPI (MSG files are OLE storage files). – Dmitry Streblechenko Mar 25 '13 at 21:38
  • Thank you, @Dmitry Streblechenko , I believe the idea of treating an MSG as an OLE storage is the idea I need. – Jacob Quisenberry Mar 26 '13 at 18:11
0

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.

Jacob Quisenberry
  • 1,131
  • 3
  • 20
  • 48