Recover readable messages into a new PST, without modifying the damaged source. damaged.pst is in the zip.
dotnet add package RecursiveAI.OneMailRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using RecursiveAI.OneMail.Pst.Recovery; if (!PstRecovery.TryOpen( "damaged.pst", out var recovery)) throw new InvalidDataException( "Cannot recover."); using (recovery) { var result = recovery!.RepairTo("recovered.pst"); Console.WriteLine($"Written: {result.Written}"); }
Written: 1Unzip the example, then dotnet run.
The full program
The download contains a locally generated Unicode original.pst with an Inbox and one message, subject Keep this message, body Locally authored recovery sample.. damaged.pst is a copy with its first 564 bytes zeroed. The original is retained for comparison; the program reads only the damaged copy.
The full program prints each item’s recovery status and scan defects, then writes recovered.pst and recovery-report.json. To use another damaged file, run dotnet run -- your-copy.pst. Keep an untouched backup before working with your own archive; recovery is not a guarantee that every message or property survives.
using RecursiveAI.OneMail.Pst.Recovery; string source = args.Length > 0 ? args[0] : "damaged.pst"; if (!PstRecovery.TryOpen(source, out var recovery)) throw new InvalidDataException("No recoverable PST structure."); using (recovery) { Console.WriteLine($"Header usable: {recovery!.HeaderUsable}"); Console.WriteLine($"Index rebuilt: {recovery.IndexRebuilt}"); foreach (var item in recovery.EnumerateItems()) Console.WriteLine($"{item.Provenance.Status}: {item.Message.Subject}"); foreach (var defect in recovery.Defects) Console.WriteLine($"Defect: {defect.Kind}"); var summary = recovery.RepairTo("recovered.pst", "recovery-report.json"); Console.WriteLine($"Written: {summary.Written}; failed: {summary.Failed}"); }
dotnet run prints:
Header usable: False Index rebuilt: True Orphaned: Keep this message Defect: HeaderUnusable Defect: HeaderUnusable Defect: NodeIndexRebuilt Written: 1; failed: 0
If no recoverable structure is found, the program throws InvalidDataException; RepairTo rejects the source as its output and overwrites an existing destination.
Variations
Include forensic candidates. This complete snippet enables scanning for deleted, stale and free-space items as well as ordinary recovery candidates. The generated damaged sample still yields one orphaned item.
using RecursiveAI.OneMail.Pst.Recovery; var options = new PstRecoveryOptions { Forensic = true }; if (!PstRecovery.TryOpen("damaged.pst", out var recovery, options)) throw new InvalidDataException("Cannot recover."); using (recovery) foreach (var item in recovery!.EnumerateItems()) Console.WriteLine(item.Provenance.Status);
OrphanedRelated recipes
The short answer
Use PstRecovery.TryOpen to read recoverable structures, inspect the recovered items and their provenance, then call RepairTo with a different destination path. OneMail writes a new Unicode PST and, when requested, a JSON recovery report. It reads the damaged source without modifying it.
PstRecovery also handles OST files, including 4 KiB OST files; the recovered output is a new Unicode PST.
Recovery is salvage, not a promise to reconstruct every item. A message may survive without its recipients, attachment tables or some properties. The recovery documentation explains which structures are scanned and how each recovered item is classified. Keep the original and inspect the report before treating a recovered archive as complete.
How to repair a damaged Outlook PST file?
Work from a copy, open it through PstRecovery, and choose a new output path. In the downloadable example the header has been deliberately zeroed while the rest of a small generated store remains intact. The recovery code infers the usable layout, rebuilds the index and finds the message. That specific result does not predict how much a truncated or heavily overwritten archive will yield.
The full program shows the distinction between the file-level scan and item-level results. HeaderUsable and IndexRebuilt describe how the source was opened. Each item’s Provenance.Status describes that candidate. RepairTo returns written and failed counts; the optional JSON report preserves more detail than those counts alone.
Choose output paths carefully. The API rejects using the source PST as the repaired PST, but an existing destination is overwritten. Keep the report alongside the recovered store rather than replacing it with a one-line success log. If writing is interrupted, the destination may be incomplete; retain the untouched source so you can try again with a separate destination.
How does PST recovery find messages?
Ordinary recovery reads the live structure when it can walk it cleanly. When that fails, scanning locates pages and blocks and rebuilds indexes from the recoverable structures. The library reads messages through the messaging layer using those indexes. A damaged folder hierarchy does not automatically mean the message bytes have disappeared.
The status tags matter. Live identifies reachable, whole items under the documented criteria. Orphaned identifies content not reached through the live tree; after tree damage, an intact-looking item can be orphaned because its index entry was reconstructed. Partial means required data was missing, damaged or skipped. In the sample the single message is orphaned, not live, because its source header was destroyed.
Provenance includes source ranges, lost ranges, defects and PST locators. Inspect them before concluding that a message with a readable subject has all its attachments. In particular, the docs explain that a message block found without its node cannot recover the missing node’s links to recipients and attachment tables. Recovery does not guess those links from file order.
Forensic mode expands the search to deleted, stale and free-space candidates. Enable it deliberately, as in the variation, rather than assuming every recovered candidate is current mail. An orphaned item in a damaged store is not automatically evidence of deliberate deletion: once the tree root is gone, a reconstructed current entry and a surviving deleted entry can look alike.
What can’t be recovered from a damaged PST?
The next step depends on what was damaged. If only the live indexing structures are gone but the data blocks remain, rebuilding the read view can recover more than a normal store reader exposes. If the source has been truncated, overwritten or lost blocks, absent bytes cannot be recreated by changing the output format.
Preserve both the original damaged file and the recovery report. Review recovered messages, attachments and folder placement against any independent backup available. A PST that opens is useful, but it is not evidence that every source message or folder property survived. Treat the new store as a recovery output with recorded provenance, not as an in-place repair of the original.