'Return the entire formatted message as a string.
Optional `unixfrom\' when True, means include the Unix From_ envelope
header.
This is a convenience method and may not generate the message exactly
as you intend because by default it mangles lines that begin with
"From ".  For more flexibility, use the flatten() method of a
Generator instance.'

def as_string(self, unixfrom=False):

    from email.generator import Generator
    fp = StringIO()
    g = Generator(fp)
    g.flatten(self, unixfrom=unixfrom)
    return fp.getvalue()
