Click here to Skip to main content
14,391,598 members

DBX Parser

Rate this:
4.52 (19 votes)
Please Sign up or sign in to vote.
4.52 (19 votes)
2 Jul 2009CPOL
Read Outlook Express DBX file, extract mail to EML file


The DBXParser can read an Outlook Express DBX file, and extract the raw content (MIME) to EML file, then you can use MIME parsers to get the actual subject body and attachments. It's the first and only (as far as Google tells) pure C# source code that provides simple methods to read and extract, free, pure, without over-headed third-party DLLs. ;)


I've been searching for source code to read an Outlook Express DBX file for a very long time (believe me, it's really long). I have found quite a few DBX readers/codes in other languages, such as:

But none of them are pure C#, so I made my own. It's a good way to port similar codes from another language, here I choose the DBX Parser(PHP), because it's much simpler than the C++ version:)

Where Are My DBX Files?

Your DBX files will normally be found here:

C:\Documents and Settings\{UserName}\Local Settings\
	Application Data\Identities\{Guid}\Microsoft\Outlook Express 

Take a look at {Guid}, it's different on different computers, so all you need to do is to use Directory.GetFiles() to go through all the sub folders for searching *.dbx files.

File Format

I am not going to go deep into the file format here, because there are already quite a few documents there:

How It Works

It reads the raw DBX file, without any third-party or related DLLs provided by Outlook Express. It only reads through the file, decoding byte by byte, then internally stores the position and sizes of chunks of each message in order to be used by the Extract method, because it only stores the positions, so it uses very little memory.

Using the Code

First create a new instance of DBX, then use the Parse function to read the file, it will return how many messages the DBX file contains. If it returns -1, then it means there is something wrong with the file. Then you could use the Extract method to save the content to a file or to read the content to memory.

Here goes a sample code:

using (DBX DBX = new DBX())
    int count = DBX.Parse(@"test.dbx");	//specify your DBX file here
    if (count > 0)
        for (int i = 0; i < count; i++)
            DBX.Extract(i, (i + 1) + ".eml"); //specify file to extract to
            				//or just read the content to memory
            				//string content = DBX.Extract(i);

How to Decode MIME (EML File)?

Choose any one of the following codes that you like:

Points of Interest

Because I suffered a lot while finding such code, I contribute it here as others won't have to get crazy looking for it. After porting the code from PHP, I feel that PHP is really mature. There are different kinds of PHP codes out there, and I'm really surprised to see that even PHP has such a sample code, but Java/VB/C# do not. I try to keep this code as simple as possible, read and extract, that's all, which I think fits most of the situations. If you have any comments or suggestions, please feel free to tell me, or just modify the code yourself.


  • Version 1.0 - 2009-5-1
  • Version 1.1 - 2009-5-5: some code clean up, added a VC++ code
  • Version 1.2 - 2009-7-2: fixed a problem not correctly return the exact amount of mails in some special situations, thanks to Cato.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Huisheng Chen
Product Manager
Australia Australia
I was born in the south of China, started to write GWBASIC code since 1993 when I was 13 years old, with professional .net(c#) and vb, founder of

Now I am living in Sydney, Australia.

Comments and Discussions

GeneralMy vote of 5 Pin
Sunny_Kumar_16-Jul-14 2:25
MemberSunny_Kumar_16-Jul-14 2:25 
BugIt gives wrong count (skips some emails from DBX) if the body value is null Pin
zhitesh1-Mar-12 6:36
Memberzhitesh1-Mar-12 6:36 
GeneralRe: It gives wrong count (skips some emails from DBX) if the body value is null Pin
Huisheng Chen1-Mar-12 11:34
MemberHuisheng Chen1-Mar-12 11:34 
GeneralMy vote of 5 Pin
klinkenbecker18-Jun-11 8:20
Memberklinkenbecker18-Jun-11 8:20 
GeneralOrder of files Pin
MacRaider410-Feb-10 6:23
MemberMacRaider410-Feb-10 6:23 
GeneralEmail count always -1 Pin
mhota30-Nov-09 21:18
Membermhota30-Nov-09 21:18 
GeneralRe: Email count always -1 Pin
Huisheng Chen30-Nov-09 21:55
MemberHuisheng Chen30-Nov-09 21:55 
GeneralRe: Email count always -1 Pin
Member 109748307-Aug-14 22:04
MemberMember 109748307-Aug-14 22:04 
Generaldbx error Pin
Peso19-Aug-09 23:25
MemberPeso19-Aug-09 23:25 
GeneralRe: dbx error Pin
Huisheng Chen20-Aug-09 0:43
MemberHuisheng Chen20-Aug-09 0:43 
GeneralMy vote of 1 Pin
abcd1234f10-Aug-09 9:37
Memberabcd1234f10-Aug-09 9:37 
GeneralThank you Pin
Pepsibot22-Jul-09 14:08
MemberPepsibot22-Jul-09 14:08 
Generalnice Pin
pita20002-Jul-09 22:37
Memberpita20002-Jul-09 22:37 
GeneralRe: nice Pin
Huisheng Chen3-Jul-09 0:20
MemberHuisheng Chen3-Jul-09 0:20 
I am glad that you like it Big Grin | :-D


QuestionIs it Extract only 10 Mails ? Pin
Laxmilal Menaria30-Jun-09 22:15
MemberLaxmilal Menaria30-Jun-09 22:15 
AnswerRe: Is it Extract only 10 Mails ? Pin
Huisheng Chen30-Jun-09 22:23
MemberHuisheng Chen30-Jun-09 22:23 
AnswerRe: Is it Extract only 10 Mails ? Pin
Huisheng Chen2-Jul-09 16:52
MemberHuisheng Chen2-Jul-09 16:52 
QuestionHow is it? Pin
sjun127-May-09 17:15
Membersjun127-May-09 17:15 
GeneralRe: How is it? Pin
Huisheng Chen30-May-09 1:01
MemberHuisheng Chen30-May-09 1:01 
GeneralGreat! Pin
Southmountain1-May-09 7:11
MemberSouthmountain1-May-09 7:11 
GeneralRe: Great! Pin
Huisheng Chen1-May-09 17:46
MemberHuisheng Chen1-May-09 17:46 
Generalplease give comment or suggestions Pin
Huisheng Chen1-May-09 5:20
MemberHuisheng Chen1-May-09 5:20 
GeneralUnveil ... Pin
adatapost1-May-09 0:26
Memberadatapost1-May-09 0:26 
GeneralRe: Unveil ... Pin
Huisheng Chen1-May-09 5:19
MemberHuisheng Chen1-May-09 5:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 30 Apr 2009


38 bookmarked