How to Recover Corrupted OST/PST File using Aspose.Email for .NET?

How can i recover a corrupted ost / pst file?

@alibardisk

Thank you for contacting support.

We would like to share with you that you may read OST files or convert them to PST and other supported file formats with Aspose.Email Product Family, but a corrupted file may not be recovered or repaired with any API offered by Aspose.

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

@alibardisk,
Reading corrupted OST/PST files may throw exceptions. But starting with version 21.8.1, Aspose.Email provides a traversal API for reading messages avoiding exceptions as shown below:

using (PersonalStorage pst = new PersonalStorage(ExceptionHandler))
{
    if (pst.Load(folderPath + "test.pst"))
    {
        GetAllMessages(pst, pst.RootFolder);
    }
}
private static void ExceptionHandler(TraversalAsposeException exception, string itemId)
{
    // Exception handling code
}
private static void GetAllMessages(PersonalStorage pst, FolderInfo folder)
{
    foreach (var messageEntryId in folder.EnumerateMessagesEntryId())
    {
        MapiMessage message = pst.ExtractMessage(messageEntryId);
        // ...
    }

    foreach (FolderInfo subFolder in folder.GetSubFolders())
    {
        GetAllMessages(pst, subFolder);
    }
}

API Reference: [PersonalStorage Class](https://reference.aspose.com/email/net/aspose.email.storage.pst/personalstorage), [TraversalExceptionsCallback Delegate](https://reference.aspose.com/email/net/aspose.email.storage.pst/traversalexceptionscallback)