'Get the message text from the email.
Will look for text/plain or use text/html if not found.'

@staticmethod
def get_msg_text(email_message):

    message_text = None
    message_html = None
    message_untyped_text = None
    for part in email_message.walk():
        if (part.get_content_type() == CONTENT_TYPE_TEXT_PLAIN):
            if (message_text is None):
                message_text = part.get_payload()
        elif (part.get_content_type() == 'text/html'):
            if (message_html is None):
                message_html = part.get_payload()
        elif part.get_content_type().startswith('text'):
            if (message_untyped_text is None):
                message_untyped_text = part.get_payload()
    if (message_text is not None):
        return message_text
    if (message_html is not None):
        return message_html
    if (message_untyped_text is not None):
        return message_untyped_text
    return email_message.get_payload()
