awesome-wm-widgets/EmailWidget/getUnreadEmailsNum.py

17 lines
280 B
Python
Raw Normal View History

2015-08-29 09:18:20 +02:00
#!/usr/bin/python
import imaplib
import email
M=imaplib.IMAP4_SSL("imap.whatever.com", 993)
M.login("username","password")
status, counts = M.status("INBOX","(MESSAGES UNSEEN)")
if status == "OK":
unread = int(counts[0].split()[4][:-1])
else:
unread = "N/A"
print(unread)