When attempting to extract messages from a PST file we are getting the following error:
class com.aspose.email.system.exceptions.InvalidOperationException: Could not read message. The message data is probably corrupted. —> class com.aspose.email.system.exceptions.ArgumentNullException: Could not find the data block by its identifier.
Parameter name: entry
com.aspose.email.zaqn.b(SourceFile:318)
com.aspose.email.zaqn.d(SourceFile:1360)
com.aspose.email.zzm.h(SourceFile:526)
com.aspose.email.zzm.(SourceFile:98)
com.aspose.email.zavq.(SourceFile:66)
com.aspose.email.zahr.a(SourceFile:328)
com.aspose.email.zavz.b(SourceFile:347)
com.aspose.email.zavz.a(SourceFile:305)
com.aspose.email.PersonalStorage.extractMessage(SourceFile:691)
com.aspose.email.PersonalStorage.extractMessage(SourceFile:707)
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/discoursExtractPst.zip (879 Bytes)
e_instance3/50443">AsposeTicket.zip (8.5 MB)
@dmckinney,
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.
@aweech,
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).
@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() {
@Override
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: