How to use new email package to read a mailbox?
duder
duder at nope.com
Thu Oct 31 21:47:42 EST 2002
On Thu, 31 Oct 2002 19:16:28 +0000, Andrew Koenig wrote:
> ark> Suppose I have a file that represents a Unix mailbox. What's the
> ark> right idiom to use to process each message in that file using the
> ark> new email package?
>
> PS: What if my file might be the standard input and therefore cannot
> be assumed to be seekable?
is this what you are looking to do?
import email
theMail = sys.stdin.read()
msg = email.message_from_string(theMail)
theBody = msg.get_payload()
theSubject = msg.get("Subject")
theDate = msg.get("Date")
More information about the Python-list
mailing list