100 Scripts in 30 Days challenge: Script 1 — Finding un-read mails using python

DailyPriyab
gopy
Published in
2 min readApr 10, 2017

This is my first script in my 100 Scripts in 30 Days challenge which I will be writing in Python to learn more new things and to automate my life. I know its not easy but at least I can see if I am upto it.

Finding un-read mails using python

I am a very lazy fellow and have a lot of emails in my inbox which are left unread. Despite my sincere efforts I have thousands of emails dating back many years which are unread. Till now I have never made a sincere effort to read them or analyze them as to how many are useful and how many are spam. So as a start I want to list down the senders and subjects of the emails that I have not read and decide what to do about them later which can be another script.

In this code I have a folder conf where I save the config for my email services as conf_<service name>.toml and in the format given below config_sample.toml.

My code imap_unread_mails.py reads the unread emails and then write the from and subject details to a csv file for me to read or process later and also shows how many are unread. Its still not a perfect script as I am getting some UTF errors but will fix it soon and re-share it. For now its working and I am happy.

For any questions tweet me at https://twitter.com/twitmyreview or mail me at bobquest33@gmail.com

Code given below:

--

--

DailyPriyab
gopy
Editor for

Data Engineering | Data Governance | Azure | Spark | Python | Manager