def getMessagePayload(self,part): fp = StringIO.StringIO() g = EmailGenerator(fp, mangle_from_=False) g.flatten(part, unixfrom=False) return fp.getvalue()
def mime_to_string(mime, header_len=0): fp = StringIO() g = MIMEGenerator(fp, mangle_from_=False, maxheaderlen=header_len) g.flatten(mime) return fp.getvalue()