Reading a Directory of Emails - Problems
Joshua J. Kugler
joshua at eeinternet.com
Tue Jul 24 18:28:11 EDT 2007
On Tuesday 24 July 2007 09:38, Ryan Rosario wrote:
> 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).
I fought with this a while back. It seems it is nested one level lower.
You might have to get at the message by doing something like
real_message = msg[0]
Instead of print msg.keys(), just do a 'print msg' and see what data
structure is returned. That will tell you a lot.
j
--
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/ ID 0xDB26D7CE
More information about the Python-list
mailing list