I am using this code:
import imaplibmail = 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 stringlatest_email_id = id_list[-1] # get the latestresult, data = mail.fetch(latest_email_id, "(RFC822)") # fetch the email body (RFC822) for the given IDraw_email = data[0][1] # here's the body, which is raw text of the whole email# including headers and alternate payloadsprint raw_email
and it works, except, when I print raw_email
it returns a bunch of extra information, how can I, parse, per say, the extra information and get just the From and body text?