python imaplib to get gmail inbox subjects titles and sender name
问题 I'm using pythons imaplib to connect to my gmail account. I want to retrieve the top 15 messages (unread or read, it doesn't matter) and display just the subjects and sender name (or address) but don't know how to display the contents of the inbox. Here is my code so far (successful connection) import imaplib mail = imaplib.IMAP4_SSL('imap.gmail.com') mail.login('mygmail@gmail.com', 'somecrazypassword') mail.list() mail.select('inbox') #need to add some stuff in here mail.logout() I believe