Hi, is there any way, in Python, to have access to an e-mail account (I'll need this for gmail but better if any works) and be able to see the number of messages in the inbox (maybe even unread messages only)? Thank you.
An alternate gmail specific solution for finding unread messages:
Gmail offers atom feeds for messages. For example:
https://mail.google.com/mail/feed/atom/ (unread messages in inbox) http://mail.google.com/mail/feed/atom/labelname/ (unread messages in labelname) http://mail.google.com/mail/feed/atom/unread/ (all unread messages)
So you could use the excellent feedparser library to grab the feed and count the entries.
Now that I'm looking at it, though, it appears that the unread messages feed only returns up to 20 entries, so this might be a bit limited.
u Can Try This One
import imaplib
obj = imaplib.IMAP4_SSL('imap.gmail.com', 993)
obj.login('username', 'password')
obj.select('Inbox') <-- it will return total number of mail in Inbox i.e ('OK', ['50'])
obj.search(None,'UnSeen') <-- it will return the list of uids for Unseen mails