https://github.com/vbharadwaj-bk/sheets-email-bot
Email bot that allows pulling from Google sheets and sending emails to listed recipients.
https://github.com/vbharadwaj-bk/sheets-email-bot
Last synced: about 2 months ago
JSON representation
Email bot that allows pulling from Google sheets and sending emails to listed recipients.
- Host: GitHub
- URL: https://github.com/vbharadwaj-bk/sheets-email-bot
- Owner: vbharadwaj-bk
- Created: 2022-03-24T23:55:26.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-18T19:37:33.000Z (about 3 years ago)
- Last Synced: 2025-01-29T01:51:14.419Z (4 months ago)
- Language: Python
- Size: 369 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Email Bot with Google Sheets and Gmail
You only need to do these steps once, and then you can write and run
as many email / spreadsheet bots as you'd like. You can also access all other
Google services through Python.Last updated 04/18/2022.
1. Clone the repository
```
git clone https://github.com/vbharadwaj-bk/sheets-email-bot.git
```2. Install Dependencies with pip:
```
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
```3. Head to the [Google Cloud Console](https://console.cloud.google.com)
4. Click "Select Project"

5. Create a new project and give it a name. You may need to browse
for a location to put the project under.
6. On the left-hand side, click APIs and Services -> Credentials. Create
a new OAuth 2.0 Credential. You will need to configure a consent screen first.
7. On the consent screen configuration, select "External", but if your Google account is part of
an organization like Berkeley or LBL, you can press "Internal", and it's easier.
Fill out the rest of the
information on the first screen. On the "scopes" page, don't select any scopes.
On the "Test Users" page (which will only appear if you clicked "External"), type in your own email
address.
8. Go back to Credentials on the left hand pane; you can now create a new Oauth key without
interruption. Name the credential something arbitrary. You will get to a screen as shown below, that
will let you download your credentials as a json. Download the json credentials file
and save it within the downloaded repository (next to `email_bot.py`) with the name "credentials.json".
9. Click "APIs and Services -> Library" from the left-hand pane. You can also search this in
the taskbar at the top.
10. Search and enable the Gmail API (first search result, click on it, enable).

11. Search and enable the Google Sheets API (same as above)

12. Run the email bot using Python! You can find the ID of a
Google spreadsheet in the URL bar, as shown in the image below,
right after /d/ and before /view or /edit; it's the long string
of characters (there's an example below the picture).
Once you
run the program from your terminal, you will be prompted to log into
your Google account on a browser (the token is then cached, so
you won't have to do this multiple times. You must reauthenticate
if you add scopes / permissions). This email bot will wait two
seconds between each email to avoid triggering spam detection.The command below has a publicly available example spreadsheet;
copy this spreadsheet, replace the values, and provide the
new spreadsheet ID to the bot. Here is the
[example spreadsheet](https://docs.google.com/spreadsheets/d/1MrcX6Go1F4B9ZC7_0FaPyn6PZGwljWht-0gk_tUg8vw/edit?usp=sharing).```
python3 email_bot.py [email protected] 1MrcX6Go1F4B9ZC7_0FaPyn6PZGwljWht-0gk_tUg8vw
```