We are currently using Aspose Email for Java 19.3 to save items from a PST as MSGs. Using the PersonalStorage.saveMessageToFile
API we are able to save a given item to a temporary file on disk. For the most part this works as expected–the files on disk are valid MSG files and can be opened individually in Outlook. However, we are seeing in some cases the files written to disk are valid OLE32 objects but not valid MSGs according to Outlook. We have tried using Outlook 2010 and Outlook 2016–both fail to open.
Following are some observations that we’ve collected in troubleshooting this issue:
Double-click: Cannot start Microsoft Outlook. Cannot read the item.
Viewing in lower-level tools such as hex viewers and CFB structured storage readers confirm that at least some of the data is there and in the expected format. For instance, I can see a stream named “__substg1.0_001A001F” which contains the bytes for “IPM Note” however attempting to open this item with anything that seemingly tries to parse a message from the streams and storages throws an error such as the Outlook dialog referenced above. Another application, MFCMapi (GitHub - microsoft/mfcmapi: MFCMAPI) gives the following error:
0x131c 03:57:32.782AM 10-25-2019 0x00000001: MyStgOpenStorage: Opening "D:\path\aspose_exploded.msg", bBestAccess == True
0x131c 03:57:32.800AM 10-25-2019 0x00080000: Enter GetPrivateMAPI
0x131c 03:57:32.801AM 10-25-2019 0x00080000: Exit GetPrivateMAPI, hinstPrivateMAPI = 72100000
0x131c 03:57:32.803AM 10-25-2019 0x00080000: Enter GetPrivateMAPI
0x131c 03:57:32.804AM 10-25-2019 0x00080000: Exit GetPrivateMAPI, hinstPrivateMAPI = 72100000
0x131c 03:57:32.805AM 10-25-2019 0x40000000: Function call: c:\projects\mfcmapi\core\mapi\mapifile.cpp@65: OpenIMsgOnIStg( nullptr, MAPIAllocateBuffer, MAPIAllocateMore, MAPIFreeBuffer, lpMalloc, nullptr, pStorage, nullptr, 0, 0, &lpMessage)
0x131c 03:57:32.808AM 10-25-2019 0x00000040: Error:
Code: MAPI_E_CORRUPT_DATA == 0x8004011B
Function OpenIMsgOnIStg( nullptr, MAPIAllocateBuffer, MAPIAllocateMore, MAPIFreeBuffer, lpMalloc, nullptr, pStorage, nullptr, 0, 0, &lpMessage)
File c:\projects\mfcmapi\core\mapi\mapifile.cpp Line 65
If I locate the message within the PST (I am able to match the entry id) and drag out to the desktop, Outlook is able to create an openable MSG file.
I also noticed that the Outlook-created version contains two 0-byte streams “__substg1.0_0E02001F” and “__substg1.0_0E03001F” (BCC, CC I believe) that are missing from the Aspose-created MSG. Manually creating these streams in a modified version of the Aspose message did NOT yield an openable item.
I feel like there are either missing fields or some kind of internal consistency error, but have not been able to prove it as of yet. Unfortunately, we are unable to provide a sample unless we can reproduce it with non-sensitive data. If it’s helpful, I can provide a listing of the streams/storages and their sizes so you can get a sense for the internal structure of the items.