Thunderbird

edit

Thunderbird stores a local folder in an mbox file (read with MboxReader), and its summary next to it, in a file with the same name and the .msf extension: the headers it shows in the list of messages, the flags, and the position of each message in the mbox file. The summary is a Mork database, a text format of Mozilla.

Summaries

ThunderbirdSummary.ReadMessages reads the messages of a summary: their subject, sender, recipients, identifiers, dates, flags, size and Offset in the mbox file:

var messages = ThunderbirdSummary.ReadMessages(path);
var first = messages[0];
Assert.Equal("First", first.Subject);
Assert.Equal("first@example.com", first.MessageId);
Assert.Equal(new DateTimeOffset(2025, 7, 1, 8, 52, 37, TimeSpan.Zero), first.Date);
Assert.True(first.Flags.HasFlag(ThunderbirdMessageFlags.Read));

// The position of the message in the mbox file of the folder
Assert.Equal(421, messages[1].Offset);

Thunderbird removes Re: from the subjects it stores, and sets HasRe instead. ThunderbirdSummary.Create writes a summary of messages, with the columns above. Thunderbird keeps more in its summaries (threads, folder information): it rebuilds a summary that does not match its folder, so a written summary is mostly useful to other tools.

Mork databases

MorkDocument reads and writes any Mork database: the summaries, and the .mab address books of the old versions of Thunderbird. It has tables of rows, and the cells of a row by column name:

var document = MorkDocument.Load(path);
var table = document.FindTable("ns:msg:db:table:kind:msgs")!;
Assert.Equal("First", table.Rows[0]["subject"]);
Assert.Equal("Café", table.Rows[1]["subject"]);

The reader resolves the dictionaries of the columns and of the values, and applies the transactions of the file (the groups @$${...}@ that Thunderbird appends when it updates a summary); it ignores the aborted ones. The values are decoded as UTF-8. The writer writes a dictionary of the names of the columns and of the scopes, then the tables and the rows.