Read an Email via Python
Hi, today I've looked for a script that can let me to read emails through it. Here what I found: import imaplib import email msrvr = imaplib.IMAP4_SSL("imap.gmail.com", 993) msrvr.login("insert_your_email@gmail.com", "insert_your_password") status, cnt = msrvr.select("Inbox") stat, dta = msrvr.fetch(cnt[0], "(UID BODY[TEXT])") result, data = msrvr.uid("search", None, "ALL") inbox_item_list = data[0].split() most_recent = inbox_item_list[-1] oldest = inbox_item_list[0] result2, email_data = msrvr.uid("fetch", oldest, "(RFC822)") raw_email = email_data[0][1].decode("UTF-8") email_message = email.message_from_string(raw_email) #print(email_message["From"]) print(dta[0][1].decode("UTF-8")) msrvr.close() msrvr.logout() and there's the email text in print(dta[0][1].decode("UTF-8")). But now I have three questions to ask you: 1) How should I do to print who sent to me the email? I tried with print(email_message["From"]), but every time it says me: The Google community team <googlecommunityteam-noreply@google.com> 2) Then, how to print the email title? 3) And the arrival time? Thanks in advice, guys :))