summaryrefslogtreecommitdiff
path: root/EmailWidget/getUnreadEmailsNum.py
diff options
context:
space:
mode:
Diffstat (limited to 'EmailWidget/getUnreadEmailsNum.py')
-rw-r--r--EmailWidget/getUnreadEmailsNum.py16
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)