I have an email that looks like this after I extract the body using the mail_message.body() function:
From nobody Sat Mar 29 12:59:23 2014
content-transfer-encoding: 7bit
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
test name
Is there an easy way to strip the header lines? I just want to extract "test name" and whatever else is after that in the email body. Thank you
Usually the headers are separated with body by two newlines. So you can use this where it is replacing everything before the first two newlines.
body = re.sub("^[\s\S]*?[\n\r][\n\r]", "", body)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments