Python Gmail Checker

by sarju7 in Circuits > Computers

5885 Views, 27 Favorites, 0 Comments

Python Gmail Checker

15, 11:07 AM.jpg

If you're like me then you probably don't check your email often just because you forget or don't want to waste your time if there are no new emails. Then all your emails pile up and you have to go through all of them all at once. Well today that stops. I am going to show you step by step how to run a Python script I wrote that will run every hour through windows task scheduler and open up gmail if you have any unread messages. It should take about 20 minutes so if you have time now let's get to it.

Download Python

apple-touch-icon-144x144-precomposed.png

Download PyCharm

images.png

Download the community version here

www.jetbrains.com/pycharm/download/#tabs_1=windows

In PyCharm Create a .py File

hello.png

It should be under File, New, then click python file name it whatever. I named mine hi.

Put Code Into File and Run

Untitled.png

REPLACE USERNAME with the part in your email address before the @ and PASSWORD with your password

import imaplib

import webbrowser

obj = imaplib.IMAP4_SSL('imap.gmail.com','993')

obj.login('USERNAME','PASSWORD')

obj.select() unread = str(obj.search(None, 'UNSEEN'))

print(unread)

print(len(unread) - 13)

if (len(unread) - 13) > 0: webbrowser.open('http://gmail.com')


RUN the file by clicking run then the file name. If it fails go on to the next step. If not go to the step after the next step.

Turn Down Security

Untitled.png

Go to this page

www.google.com/settings/security/lesssecureapps

then set access to less secure on

Run It Again

This time run the script and there should be no errors

Open Windows Task Scheduler

Untitled.png

Search for windows task scheduler in the program search bar

Create a Task

Follow these instructions here to create the task

Sorry I dont know how to expain this part.

http://blogs.esri.com/esri/arcgis/2013/07/30/sched...

Done

December 22, 2015

Now every hour or whatever interval you set it at the program will run and open gmail if you have unread messages.

Here is a video of it in action.