On 6/14/2012 12:57 PM Ryan Clough said...
Hello everyone,

Is anyone familiar with a simple way to parse mbox emails in Python?

>>> import mailbox
>>> help(mailbox)
Help on module mailbox:

NAME
mailbox - Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.


Emile

I
use Mail::MBoxParser in perl and it provides a simple way to grab the
bodies from the emails. In my research online, people have suggested
searching for lines starting with "From ", but this doesn't seem
reliable to me. I am using the built in mailbox module and am able to do
something like:

import mailbox
for message in mbox:
print message['subject']

It would be great if you could do something like the following:
print messages['body']

Any thoughts are appreciated.

Thanks, Ryan




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to