Skip to content

Instantly share code, notes, and snippets.

@bollovan
Created September 9, 2011 19:14

Revisions

  1. bollovan created this gist Sep 9, 2011.
    22 changes: 22 additions & 0 deletions gistfile1.python
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #! /usr/bin/python2
    import os
    import string
    import urllib

    #Enter your username and password below within double quotes
    # eg. username="username" and password = "password"
    username = "user"
    password = "pass"

    com = urllib.urlopen("https://" + username + ":" + password + "@mail.google.com/mail/feed/atom")

    temp = com
    msg = temp.read()
    index = string.find(msg, "<fullcount>")
    index2 = string.find(msg, "</fullcount>")
    fc = int( msg[ index + 11:index2 ] )

    if fc == 0:
    print "no new emails"
    else:
    print str(fc) + " new emails"