#NEWLINE# def get_message_body( email_message ) : #NEWLINE# #INDENT# 'Walk through the message parts, taking the first text/plain.\n       if no text/plain (is this allowed?) will return the first\n       text/html' #NEWLINE# candidate = None #NEWLINE# if email_message . is_multipart ( ) : #NEWLINE# #INDENT# for message_part in email_message . walk ( ) : #NEWLINE# #INDENT# if is_plaintext ( message_part ) : #NEWLINE# #INDENT# return message_part #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( is_text ( message_part ) and ( candidate is not None ) ) : #NEWLINE# #INDENT# candidate = message_part #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return email_message #NEWLINE# #UNINDENT# return email_message