msg.walk()
Samuel Wright
lykoszine at gmail.com
Sat Jun 26 10:30:04 EDT 2004
Hi Guys
Using Python 2.3 here, trying to parse a MBOX email file using the code below:
------------------------
mailboxfile = 'emails.txt'
import email
import email.Errors, email.Parser, email.Message
import mailbox
def msgfactory(fp):
try:
return email.message_from_file(fp)
except email.Errors.MessageParseError:
# Don't return None since that will
# stop the mailbox iterator
return ''
def main():
fp = open(mailboxfile, 'r')
mbox = mailbox.UnixMailbox(fp, msgfactory)
for msg in mbox:
print msg
for part in msg.walk():
print part
if __name__=="__main__":
main()
---------------------
not much there that isn't in the examples. Anyway, says I can't use
walk() on a string (msg)! Suggestions?
More information about the Python-list
mailing list