Python read gmail


Asked by wiki @ & viewed by 15 persons


Reading Gmail Email in Python

I am attempting to create a simple script to check my Gmail for emails with a certain title. When I run this program on Python 3.7.3 I receive this data: ('OK', [b'17']).

I need to access the body of the email within python. I am just not sure what to do with the data that I have.

Here is my current code:

import imaplib
import credentials

imap_ssl_host = 'imap.gmail.com'
imap_ssl_port = 993
username = credentials.email
password = credentials.passwd
server = imaplib.IMAP4_SSL(imap_ssl_host, imap_ssl_port)

server.login(username, password)
server.select('INBOX')

data = server.uid('search',None, '(SUBJECT "MY QUERY HERE!")')
print(data)

The result from running the code:

('OK', [b'17'])

I know it is a little rough, but I am still learning, so any advice you have to help me improve would be greatly appreciated!

Do you know the better answer?

Similar questions

Gmail api read email python

Asked by wiki @ & viewed by 9 persons

How to retrieve the whole message body using Gmail API (python) I want to extract the whole message body of …

Gmail api python read email

Asked by wiki @ & viewed by 9 persons

Gmail API: How to simply authenticate a User and get a list of their messages? I'm trying to build a …

Python gmail read email

Asked by wiki @ & viewed by 12 persons

Reading Gmail Email in Python I am attempting to create a simple script to check my Gmail for emails with …

Read data from azure data lake using python

Asked by wiki @ & viewed by 9 persons

Python code to access Azure Data Lake Store I 'm looking at Microsoft Documentation here and here, I have created …

Read a excel file in python

Asked by wiki @ & viewed by 6 persons

Reading Excel File using Python, how do I get the values of a specific column with indicated column name? I've …

Read csv sep tab python

Asked by wiki @ & viewed by 5 persons

Reading tab-delimited file with Pandas - works on Windows, but not on Mac I've been reading a tab-delimited data file …

Python pandas read_csv unicodedecodeerror

Asked by wiki @ & viewed by 6 persons

UnicodeDecodeError when reading CSV file in Pandas with Python I'm running a program which is processing 30,000 similar files. A …

Read a binary file python

Asked by wiki @ & viewed by 5 persons

Reading a binary file with python I find particularly difficult reading binary file with Python. Can you give me a …

Python read parquet file

Asked by wiki @ & viewed by 6 persons

How to read a Parquet file into Pandas DataFrame? How to read a modestly sized Parquet data-set into an in-memory …

Python read multiple excel files

Asked by wiki @ & viewed by 6 persons

Import multiple excel files into python pandas and concatenate them into one dataframe I would like to read several excel …

How to read json file in python pandas

Asked by wiki @ & viewed by 7 persons

Read json file as pandas dataframe? I am using python 3.6 and trying to download json file (350 MB) as …

How to read a zip file in python

Asked by wiki @ & viewed by 9 persons

Python: Open file in zip without temporarily extracting it How can I open files in a zip archive without extracting …

Python read csv into dictionary of lists

Asked by wiki @ & viewed by 5 persons

Most Pythonic way to read CSV values into dict of lists I have a CSV file with headers at the …

Read excel data python

Asked by wiki @ & viewed by 7 persons

Reading Excel File using Python, how do I get the values of a specific column with indicated column name? I've …

Python read data from arduino

Asked by wiki @ & viewed by 5 persons

python to arduino serial read & write I'm trying to "ping pong" info back and forth between some python code …

Most viewed questions


Python strftime milliseconds

Asked by wiki @ & viewed by 201 persons

Format a datetime into a string with milliseconds I want to have a datetime string from the date with milliseconds. …

What does the percent sign mean in python

Asked by wiki @ & viewed by 136 persons

What does the percentage sign mean in Python In the tutorial there is an example for finding prime numbers: >>> …

Self keyword in python

Asked by wiki @ & viewed by 135 persons

What is the purpose of the word 'self'? What is the purpose of the self word in Python? I understand …

Check object type python

Asked by wiki @ & viewed by 133 persons

Determine the type of an object? Is there a simple way to determine if a variable is a list, dictionary, …

Correlation matrix python

Asked by wiki @ & viewed by 132 persons

Plot correlation matrix using pandas I have a data set with huge number of features, so analysing the correlation matrix …

Alphabetical sort python

Asked by wiki @ & viewed by 131 persons

Python data structure sort list alphabetically I am a bit confused regarding data structure in python; (),[], and {}. I …

Python random

Asked by wiki @ & viewed by 127 persons

Generate random integers between 0 and 9 How can I generate random integers between 0 and 9 (inclusive) in Python? …

Python one line for loop

Asked by wiki @ & viewed by 124 persons

Python one-line “for” expression I'm not sure if I need a lambda, or something else. But still, I need the …

How to add a column to dataframe python

Asked by wiki @ & viewed by 124 persons

Adding new column to existing DataFrame in Python pandas I have the following indexed DataFrame with named columns and rows …

Python create dataframe from list

Asked by wiki @ & viewed by 124 persons

Python: create a pandas data frame from a list I am using the following code to create a data frame …

Why we use self in python

Asked by wiki @ & viewed by 116 persons

What is the purpose of the word 'self'? What is the purpose of the self word in Python? I understand …

Shape 0 python

Asked by wiki @ & viewed by 115 persons

x.shape[0] vs x[0].shape in NumPy Let say, I have an array with x.shape = (10,1024) when I try to print …

Python print working directory

Asked by wiki @ & viewed by 113 persons

Find current directory and file's directory [duplicate] This question already has answers here: How do you properly determine the current …

Image shape python

Asked by wiki @ & viewed by 110 persons

Python OpenCV2 (cv2) wrapper to get image size? How to get the size of an image in cv2 wrapper in …

Interface grafica python

Asked by wiki @ & viewed by 108 persons

Como criar interface gráfica em Python? [duplicada] Essa pergunta já tem uma resposta aqui: É possível criar interfaces gráficas para …