Get the first text part we can find and print it as a message.

        This is a simple cowpath, most of the time you want the first plain part.

        'msgid' is the message to be used
        'stream' is printed to with the header, splitter, first-textpart
        'splitter' is text used to split the header from the body, Emacs uses this

def gettext(self, msgid, stream=sys.stdout, splitter="--text follows this line--\n"):
        """Get the first text part we can find and print it as a message.

        This is a simple cowpath, most of the time you want the first plain part.

        'msgid' is the message to be used
        'stream' is printed to with the header, splitter, first-textpart
        'splitter' is text used to split the header from the body, Emacs uses this
        """
        for hdr,part in self._get(msgid):
            if part.get_content_type() == "text/plain":
                for name,val in hdr:
                    # Use the subtype, since we're printing just that - tidy it up first
                    if name.lower() == "content-type":
                        val = part["content-type"]
                    val = " ".join([l.strip() for l in val.split("\n")])
                    print("%s: %s" % (name,val), file=stream)
                print(splitter, file=stream)
                payload = part.get_payload(decode=True)
                # There seems to be a problem with the parser not doing charsets for parts
                chartype = part.get_charset() \
                    or _get_charset(part.get("Content-Type", "")) \
                    or "us-ascii"
                print(payload.decode(chartype), file=stream)
                break