Search code examples
c#emailmimembox

Reading an mbox file in C#


One of our staff members has lost his mailbox but luckily has a dump of his email in mbox format. I need to somehow get all the messages inside the mbox file and squirt them into our tech support database (as its a custom tool there are no import tools available).

I've found SharpMimeTools which breaks down a message but not allow you to iterate through a bunch of messages in a mbox file.

Does anyone know of a decent parser thats open without having to learn the RFC to write one out?


Solution

  • I don't know any parser, but mbox is really a very simple format. A new email begins on lines starting with "From " (From+Space) and an empty line is attached to the end of each mail. Should there be any occurence of "From " at the beginning of a line in the email itself, this is quoted out (by prepending a '>').

    Also see Wikipedia's entry on the topic.