---
title: "Read Outlook Express DBX email in C#"
url: https://recursiveai.org/onemail/cookbook/read-outlook-express-dbx-messages/
description: "Read an Outlook Express DBX folder in C# with OneMail. Extract the original bytes of each live message to its own EML file without installing Outlook Express."
version: "1.0.1"
---

Stream the live messages in the zip’s sample `Inbox.dbx` to `.eml` files with `DbxReader`.

```shell
dotnet add package RecursiveAI.OneMail
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneMail.Sources;
using RecursiveAI.OneMail.Stores.Dbx;

using var source = FileSource.Open("Inbox.dbx");
var folder = new DbxReader(source);
if (folder.Kind != DbxFileKind.MessageDatabase)
    throw new InvalidDataException("Expected a DBX message database.");
int number = 0;
foreach (var entry in folder.EnumerateMessages())
{
    if (!entry.HasMessage)
        continue;
    using var message = folder.OpenMessage(entry);
    string name = $"message-{++number}.eml";
    using var output = File.Open(name, FileMode.CreateNew);
    message.CopyTo(output);
    Console.WriteLine($"{name}: {output.Length} bytes");
}
```

Paste the code above into Program.cs of a new `dotnet new console` project and `dotnet run`, or unzip [the example](https://recursiveai.org/onemail/cookbook/read-outlook-express-dbx-messages/read-outlook-express-dbx-messages.zip) and `dotnet run`.

```text
message-1.eml: 77 bytes
message-2.eml: 81 bytes
```



Here’s the first of the two messages in the sample `Inbox.dbx`, shown as email text:

```text
From: lee@example.com
To: sam@example.com
Subject: Hello

First sample.
```

The program rejects `Folders.dbx` because it isn’t a message database. Run it in a fresh output directory with the input file there, or remove your previous exports before running it again: `FileMode.CreateNew` won’t overwrite them.

## Variations

**List original subjects without writing files.** With `folder` opened as above, read the indexed subject before opening any message stream:

```csharp
foreach (var entry in folder.EnumerateMessages())
    Console.WriteLine(entry.OriginalSubject);
```

```text
Hello
Reminder
```

## Related recipes

- [Read an OLM file](https://recursiveai.org/onemail/cookbook/read-olm-file/) for Outlook for Mac archives.
- [Parse an EML file](https://recursiveai.org/onemail/cookbook/parse-eml/) to work with individual messages.

## The short answer

Use `DbxReader.EnumerateMessages()` on a message folder such as `Inbox.dbx`. For each entry with `HasMessage` set, copy `OpenMessage(entry)` to a separate `.eml` file. The stream supplies the stored message bytes, so no text decoding or message reserialization is needed. This reads live entries; it doesn’t recover deleted emails.

## How do I get my emails from Outlook Express?

Start with a copy of the DBX for the folder you want to export. `Inbox.dbx` is one message database, not the whole mail store. `Folders.dbx` contains records about the folder hierarchy rather than the messages. Repeat the extraction for each message database you want. Use a separate output directory for each folder, since the sequence numbers are local to a run.

## How do I convert DBX to EML without changing the message?

A message’s bytes may be stored in several pieces. `OpenMessage` follows the chain and exposes its contents as a forward-only stream, without loading the whole email at once. Keep the DBX source open until those streams are closed and copy the stream directly to the output. That preserves the stored headers and body bytes, including any MIME-encoded attachments already in the message. Outlook Express’s folder flags and indexed fields are not part of that stream; keep the DBX if you also need the folder metadata.

## Can you recover deleted messages from a DBX file?

Not by enumerating the live index. Outlook Express removes a deleted message’s entry from that index. A live record can also exist without a text chain, for example if only the header was downloaded; the example skips these entries. Deleted-message recovery is a separate operation, and some bytes may be missing or overwritten. See the [DBX recovery notes](https://recursiveai.org/onemail/docs/recovery/#dbx-deleted-and-orphaned-messages) for what it can and can’t retrieve.
