def METHOD_NAME(msg):
    # Decode=True argument handles quoted-printable and Base64 encoding.
    # parts variable may be a string or a list (in the case of a multi-part
    # message).
    parts = msg.get_payload(decode=True)
    content_type = msg.get_content_type()
    msg_txt = None
    if content_type == 'text/html':
        if isinstance(parts, list) or isinstance(parts, tuple):
            pass
        # If this is a bytes, we need to decode it
        elif isinstance(parts, bytes):
            charset = msg.get_charset()
            if charset is None:
                msg_txt = parts.decode('utf-8')
            else:
                msg_txt = parts.decode(charset)
        # If it's already a str, we're good to go
        elif isinstance(parts, str):
            msg_txt = parts
        else:
            raise Exception("Message payload was neither string nor list.")
    else:
        print('Can\'t handle content type %s' % content_type)
    return msg_txt