diff options
Diffstat (limited to 'EmailWidget/getUnreadEmailsNum.py')
-rw-r--r-- | EmailWidget/getUnreadEmailsNum.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/EmailWidget/getUnreadEmailsNum.py b/EmailWidget/getUnreadEmailsNum.py new file mode 100644 index 0000000..5599f2e --- /dev/null +++ b/EmailWidget/getUnreadEmailsNum.py @@ -0,0 +1,16 @@ +#!/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) |