Hi Team,
When trying to extract the OST file getting the below error. unfortunately, I can’t share more details because it is client data. Below is the code where it is failing and the error log.
int messageNumber = 0;
Iterator iterable = folder.enumerateMessagesEntryId().iterator();
Error :
class com.aspose.email.system.exceptions.EndOfStreamException: Attempted to read past the end of the stream. com.aspose.email.internal.n.zb.a(Unknown Source) com.aspose.email.internal.n.zb.h(Unknown Source) com.aspose.email.internal.n.zb.l(Unknown Source)
com.aspose.email.zfu.a(SourceFile:586) com.aspose.email.zfu.h(SourceFile:479) com.aspose.email.zfu.(SourceFile:85) com.aspose.email.zbfh.(SourceFile:119) com.aspose.email.zahx.i(SourceFile:1692) com.aspose.email.zahx.a(SourceFile:475) com.aspose.email.zawg.i(SourceFile:1038)
com.aspose.email.FolderInfo.enumerateMessagesEntryId(SourceFile:602)
@Vamsi_452,
Thank you for the issue description.
Unfortunately, we need the OST file to investigate this case. We can make this forum thread private.
Also, you can try using a traversal API to handle corrupted messages in PST/OST files as shown below:
public static void main(String[] args) {
TraversalExceptionsCallback exceptionsCallback = new TraversalExceptionsCallback() {
@Override
public void invoke(TraversalAsposeException exception, String itemId) {
/* Exception handling code. */
}
};
try (PersonalStorage pst = new PersonalStorage(exceptionsCallback)) {
if (pst.load("test.ost")) {
getAllMessages(pst, pst.getRootFolder());
}
}
}
private static void getAllMessages(PersonalStorage pst, FolderInfo folder) {
for (String messageEntryId : folder.enumerateMessagesEntryId()) {
MapiMessage message = pst.extractMessage(messageEntryId);
}
for (FolderInfo subFolder : folder.getSubFolders()) {
getAllMessages(pst, subFolder);
}
}
API Reference: TraversalExceptionsCallback Class
I wrote the same but the breakpoint not hitting at TraversalExceptionsCallback.
TraversalExceptionsCallback exceptionsCallback = new TraversalExceptionsCallback() {
@Override
public void invoke(final TraversalAsposeException exception, final String itemId) {
Logger.Log(“Attempting to extract folder '” + itemId + “’ from pst.”);
}
};
When it failed at this place, it should hit TraversalExceptionCallBack but it is not hitting there.
Iterator iterable = folder.enumerateMessagesEntryId().iterator();
This forum thread continues [here](https://forum.aspose.com/t/extracting-ost-file-throws-error-attempted-to-read-past-the-end-of-the-stream/237292)
.