how to retrieve attachment in a mail ?
Michael A. Josephson
mikej at well.com
Wed Oct 29 07:08:14 EST 2003
On Wed, 29 Oct 2003 09:35:03 +0100, "Didier FRAISSE"
<dfraisse at free.fr> wrote:
>BUT i don't understand how to migrate from
> response, lines, bytes = pop.retr(n+1)
>where lines is a list to a msg object
> for part in msg.walk():
The example code you've posted for parsing the message:
msg=p.parse(mailFile)
assumes that the message is coming from a file-like object (e.g. if
you're reading the message from a file on disk.)
Because you're reading the message from a POP server what you probably
want to do is join the lines together into a single string:
messagetext = string.join(lines, "\n")
and then use parsestr rather than parse to get your message object:
msg = p.parsestr(messagetext)
-Michael
More information about the Python-list
mailing list