Reading a Directory of Emails - Problems

Ryan Rosario uclamathguy at gmail.com
Tue Jul 24 19:38:47 CEST 2007


Hi,

I have a directory that contains a bunch of email messages and I would like
to parse them using the email and mailbox packages. The emails were exported
from Apple Mail. From what I gather, I need to use MHMailbox, but I can't
get it to do anything useful and I cannot find any examples of how to use
this particular mailbox type.

mbox = mailbox.MHMailbox('stat_inbox.mbox/Messages',email.message_from_file)
for msg in mbox:
    print msg.keys()          #just to see if anything is happening

I get an error. AttributeError: MHMailbox instance has no attribute 'keys'.
Yet this works when using PortableUnixMailbox (on an mbox file, not a
directory of emails).

Can someone help me use this type of mailbox? Am I even using the correct
type of mailbox for this?

Thanks,
Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070724/6761effd/attachment.html>


More information about the Python-list mailing list