email module in 2.2

Alex Russell alex at securepipe.com
Sat May 25 16:29:12 EDT 2002


Hey everyone,

I'm re-writing an email script using the new email module introduced in 
2.2, and I'm having some issues with multipart MIME messages.

Straight off, I'm unsure about how I'm getting the text-only part of the 
message. The function I'm using is as follows:

def get_message_body(self, msg_number):
    msg = self.get_message(msg_number) # gets full message text
    if not msg.is_multipart():
        return msg.get_payload()
    else:
        bndry = msg.get_boundary()
        payld = str(msg.get_payload(0))
        return string.split(string.split(payld, 
bndry)[0],'quoted-printable')[1]

what bugs me most is that I can't seem to use get_payload to return JUST 
the text/plain sections of the message. Any pointers?

Thanks in advance.

-- 
Alex Russell
alex at securepipe.com
alex at netWindows.org



More information about the Python-list mailing list