Python email
Jeffrey Froman
jeffrey at fro.man
Sun Oct 10 14:50:18 EDT 2004
LutherRevisited wrote:
> I get the message just fine, but I want to pull out of all that just the
> html part. How can I do this.
The email and email.Iterators modules offer methods for doing this. For
example:
***************************************************************
# Warning: untested code
import email
from email.Iterators import typed_subpart_iterator
inMail = derived_from_POP3_magic()
my_email = email.message_as_string(inMail)
html_parts = typed_subpart_iterator(my_email, 'text', 'html')
***************************************************************
You may also want to look at email.Iterators.body_line_iterator, useful for
bypassing the headers in each part of the email.
Jeffrey
More information about the Python-list
mailing list