Book Image

Intel Galileo Blueprints

By : Marco Schwartz
Book Image

Intel Galileo Blueprints

By: Marco Schwartz

Overview of this book

Table of Contents (19 chapters)
Intel Galileo Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Setting Up the Galileo Board and the Development Environment
Index

Printing the unread e-mails on the LCD screen


We can now print the number of unread e-mails on the LCD screen.

The code for this function is composed of two parts:

  • The Python script to connect to Gmail

  • The code to read the number of unread e-mails that you have in Gmail

We'll also need the Arduino sketch to get this number and display it on the LCD screen.

Let's look at the complete Python script first:

# Import library
import imaplib

# Connect to Gmail
obj = imaplib.IMAP4_SSL('imap.gmail.com', '993')  

# Login to Gmail
obj.login('your_gmail_address','your_gmail_password')

# Print number of unread emails
print len(obj.search(None,'UnSeen')[1][0].split())

Now, let's analyze it. The first thing that this code does is import the imaplib library:

import imaplib

Then, it connects to Gmail:

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

After this, it will enter the Gmail e-mail ID and password. You should replace the dummy characters with your own credentials:

obj.login('your_gmail_address','your_gmail_password...