Created
May 29, 2013 14:31
-
-
Save dep-deprecated/5670713 to your computer and use it in GitHub Desktop.
This script will pull an 'unread count' from your gmail inbox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python -tt | |
import sys | |
import curses | |
import imaplib | |
import warnings | |
def main(): | |
imap_server = imaplib.IMAP4_SSL("imap.gmail.com",993) | |
imap_server.login('username', 'password') | |
imap_server.select('INBOX') | |
status, response = imap_server.status('INBOX', "(UNSEEN)") | |
unreadcount = int(response[0].split()[2].strip(').,]')) | |
print unreadcount | |
imap_server.logout() | |
# This is the standard boilerplate that calls the main() function. | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment