tags:

views:

628

answers:

2

Hi,

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?

+1  A: 

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.

dseifert
This might be the easiest solution yes.
Skurmedel
And lines beginning with ">From" should be quoted ">>From", and so on.
JimG
@JimG - That would be the preferred way, though there is also a quoting scheme where this is not done (google MBOXO and MBOXRD).
dseifert
A: 

If you can stretch to using Python, there is one in the standard library. I'm unable to find any for .NET sadly.

Skurmedel
Then use IronPython?
Swaroop C H
Yes that is possible. It's easy using other .NET code from IronPython, it's hard using IronPython from other .NET though.
Skurmedel