POP text/plain
Tim Williams
listserver at tdw.net
Wed Oct 20 07:17:22 EDT 2004
"LutherRevisited" <lutherrevisited at aol.com> wrote in message
news:20041020010134.07554.00002191 at mb-m18.aol.com...
> Ok, what I do for most email messages is get the content that is type
> 'text/html', which is 99% of my messages, and with string functions I can
get a
> string from that which is only html code. But, for plain text messages,
the
> part which is text/plain doesn't really leave me with anything I can think
of
> to get a substring from that which is only the body of the message. I
always
> end up with header and all when I display a plaintext message. Any
thoughts?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Use the email module to split any email into its "parts", then work with
the parts individually
(code not tested)
import email
emailobj = email.message_from_string( whole_message)
if emailobj.is_multipart():
for part in emailobj.get_payload():
print part.get_filename()
print part.get_content_type()
print part
else:
print emailobj.get_payload()
More information about the Python-list
mailing list