IMAP obtenir le nom de l'expéditeur et le corps du texte?

Je suis en utilisant ce code:

import imaplib
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login(myusername, mypassword)
mail.list()
# Out: list of "folders" aka labels in gmail.
mail.select("inbox") # connect to inbox.

result, data = mail.search(None, "ALL")

ids = data[0] # data is a list.
id_list = ids.split() # ids is a space separated string
latest_email_id = id_list[-1] # get the latest

result, data = mail.fetch(latest_email_id, "(RFC822)") # fetch the email body (RFC822) for the given ID

raw_email = data[0][1] # here's the body, which is raw text of the whole email
# including headers and alternate payloads

print raw_email

et ça fonctionne, sauf que, quand j'ai l'impression raw_email elle renvoie un tas d'informations supplémentaires, comment puis-je, d'analyser, pour dire, les informations supplémentaires et obtenez seulement la forme et le corps du texte?

OriginalL'auteur Sam Tubb | 2013-10-23