Python Forum

Full Version: IMAPLIB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,
I'm new to python, so any help would be much appreciated.
My project is to create a script that logs in to a Gmail account and provide the
Following details:
10 latest emails from a specific sender
Email's subject
Email's Date & Time
I succeed creating a code sample that logs in to a gmail account>inbox>all mail list:

import email
import imaplib
import datetime
import email.header


username = '[email protected]'
password = 'password'

mail = imaplib.IMAP4_SSL("imap.gmail.com")
mail.login(username, password)

mail.select("inbox")

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

inbox_item_list= data[0].split()

inbox_item_list
I know a lot of stuff is missing or incorrect but thats what I'm getting from
My starting position.
Any corrections & additions would be very helpful.
Thank you