On 06/04/07, Tim Williams <[EMAIL PROTECTED]> wrote: > Content: ['text/plain', 'text/html', 'message/delivery-status', > 'text/plain', 'text/plain', 'text/plain', 'unknown', 'message/rfc822', > 'text/plain', 'text/html']
I should explain that this was the content in a single email > > # part.get_content_maintype() requires a further call > # to get_content_subtype() , so use > # part.get_content_type() instead. > > required = ['text/plain', 'text/tab-separated-values'] > for part in EMAIL_OBJ.walk(): > text_parts = [] > if part.get_content_type() in required: > text_parts.append(part) > > print ('\r\n' + '='*76 +'\r\n').join(text_parts) > # print all the text parts seperated by a line of '=' > # end Content: ['text/plain', 'text/html', 'message/delivery-status', 'text/plain', 'text/plain', 'text/plain', 'unknown', 'message/rfc822', 'text/plain', 'text/html'] Is text/html a text part or an html part for this exercise ? :) You need to walk the parts and use something like # part.get_content_maintype() requires a further call # to get_content_subtype() , so use # part.get_content_type() instead. required = ['text/plain', 'text/tab-separated-values'] for part in EMAIL_OBJ.walk(): # text_parts = [] <== oops, this should be above the for..... if part.get_content_type() in required: text_parts.append(part) print ('\r\n' + '='*76 +'\r\n').join(text_parts) # print all the text parts seperated by a line of '=' # end -- http://mail.python.org/mailman/listinfo/python-list