Getting Error when Extracting Messages from PST File

When attempting to extract messages from a PST file we are getting the following error:

class Could not read message. The message data is probably corrupted. —> class Could not find the data block by its identifier.
Parameter name: entry

This should also reproduce with Aspose sample code for message extraction. A sample file has been (3.8 MB)

1 Like

Thank you for the issue description. To help you, we need to know the following:

  • The code example reproducing the error
  • The version of Aspose.Email you used

But first, please check the issue with the latest version of Aspose.Email.

I am attaching an another sample file and sample project that we used to replicate the issue. The version we used of Aspose.Email are 21.2. and 21.3. <a class=“attachment” href="/uploads/ (879 Bytes)
e_instance3/50443"> (8.5 MB)

Unfortunately, your file has not been uploaded. Please try again. (8.5 MB)
Upload of

Thank you for the additional data. I reproduced the error and got the same result. I’ve logged the issue in our tracking system with ID EMAILJAVA-34872. Our development team will investigate this case. You will be notified when it is fixed.

Hello @Andrey_Potapov, is there any news on this issue?


I requested an estimated time to fix this issue from our development team. I will let you know as soon as possible.

@Andrey_Potapov , have you heard anything?

Our development team has investigated the issue. The exception occurs because some data in the source file is corrupted. We explored the possibility to recover corrupted data, but it did not bring any results. Now we are testing the file with new API methods that allow reading without throwing exceptions, skipping the corrupted data. This API will be available in version 21.8 (closer to the beginning of September).

@Andrey_Potapov Thank you for the update. Will there be a way to still report on the corrupted data with the new API?

I requested this information from our development team. I will let you know soon.

Our developers confirmed such a capability to detect corrupted data with the new API.

The issues you have found earlier (filed as EMAILJAVA-34872) have been fixed in this update.

@dmckinney, @aweech,
With Aspose.Email 21.8, you can extract all PST items without throwing out exceptions, even if some data of the original file is corrupted. Code snippet:

TraversalExceptionsCallback exceptionsCallback = new TraversalExceptionsCallback() {
    public void invoke(TraversalAsposeException exception, String itemId) {
        /* Exception handling  code. */

//Loading and traversal exceptions will be available through the callback method.
try (PersonalStorage pst = new PersonalStorage(exceptionsCallback)) 
    // ...

The PersonalStorage.Load method returns ‘true’ if a file is loaded successfully and further traversal is possible. If the file is corrupted and no traversal is possible, ‘false’ is returned.

For this case, PST extraction could be implemented like this:

static Map<String, Exception> exceptions = new HashMap<String, Exception>();

public static void main(String[] args) {
    TraversalExceptionsCallback exceptionsCallback = new TraversalExceptionsCallback() {
        public void invoke(TraversalAsposeException exception, String itemId) {
            exceptions.put(itemId, exception);

    try (PersonalStorage pst = new PersonalStorage(exceptionsCallback)) {
        FolderInfo rootFolder = pst.getRootFolder();
        extractFolder(pst, rootFolder, "out\\");

private static void extractFolder(PersonalStorage pst, FolderInfo folder, String outDirectory) {
    System.out.println("Processing folder " + folder.getDisplayName());
    int messageNumber = 0;

    for (String messageEntryId : folder.enumerateMessagesEntryId()) {
        String fileName = outDirectory + messageNumber;
        System.out.println("Processing messageEntryId " + messageEntryId);
        MapiMessage message = pst.extractMessage(messageEntryId);

        if (!exceptions.containsKey(messageEntryId)) {
            if ("IPM.Contact".equals(message.getMessageClass())) {
                IMapiMessageItem item = message.toMapiMessageItem();
                ((MapiContact) item).save(fileName + ".vcf", 0);
            } else {
       + ".msg", new MsgSaveOptions(MailMessageSaveType.getOutlookMessageFormat()));

    for (FolderInfo subFolder : folder.getSubFolders()) {
        extractFolder(pst, subFolder, outDirectory);

API Reference: TraversalExceptionsCallback Class, PersonalStorage Class

Hi Andrey,

How I can make it writable? when using
PersonalStorage pst = new PersonalStorage(exceptionsCallback);
pst.load( filePath)


Thank you for posting the question. My colleagues will reply to you as soon as possible.

Hello @dhawal,

Please use the fromFile method with the writable parameter:

PersonalStorage pst = PersonalStorage.fromFile(filePath, true);


Thanks or the quick resonse.

But then I can not know whether the file is traversable/corrupted or not if I use the fromFile


It’s not provided for traversal API to open a file for writing. There can be problems with editing of the corrupted files.