I can open emails using python (imap and mail modules), mostly following the advice here: How can I get an email message's text content using python?
But I need to print only the first line of every email body - how could i do that?
for part in email_message.walk():
# each part is a either non-multipart, or another multipart message
# that contains further parts... Message is organized like a tree
if part.get_content_type() == 'text/plain':
print part.get_payload() # prints the raw text
this is what i currently have to print the body, any ideas how I could restrict that to the first line of the email?