Learn how to use Gmail API to send emails, search for emails by query, delete emails, mark emails as read or unread in Python. Learn How to Use Gmail API in Python
Learn how to use Gmail API to send emails, search for emails by query, delete emails, mark emails as read or unread in Python.
Gmail is by far the most popular mail service nowadays, it's used by individuals and organizations. Many of its features are enhanced with AI, including its security (and detection of fraudulent emails) and its suggestions when writing emails.
In the previous tutorials, we explained how you can send emails as well as reading emails with Python, if you didn't read them yet, I highly recommend you check them out.
While the previous tutorials were on using the IMAP/SMTP protocols directly, in this one, we will be using Google's API to send and read emails, by doing so, we can use features that are specific to Google Mail, for example; add labels to some emails, mark emails as unread/read and so on.
For this guide, we will explore some of the main features of the Gmail API, we will write several Python scripts that has the ability to send emails, search for emails, deletes and marks as read or unread, they'll be used as follows:
$ python send_emails.py [email protected] "Subject" "Message body" --files file1.txt file2.pdf file3.png $ python read_emails.py "search query" $ python delete_emails.py "search query" $ python mark_emails.py --read "search query" $ python mark_emails.py --unread "search query"
Here is the table of contents:
To get started, let's install the necessary dependencies:
$ pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
In this post, we'll learn top 30 Python Tips and Tricks for Beginners
You can learn how to use Lambda,Map,Filter function in python with Advance code examples. Please read this article
Learn what are the most important API security threats engineering leaders should be aware of and steps you can take to prevent them
I’ve been working with Restful APIs for some time now and one thing that I love to do is to talk about APIs.
The method used for this initial research was to obtain a list of the ASX100 (as of 18 September 2020). Then work through each company looking at the following