Metadata-Version: 2.1
Name: gmail-draft-creator
Version: 1.2.0
Summary: Create draft messages in Gmail
Home-page: https://github.com/iloveitaly/gmail-draft-creator
License: MIT
Author: Michael Bianco
Author-email: mike@mikebian.co
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: click (>=8.1.3,<9.0.0)
Requires-Dist: google-api-python-client (>=2.21.0,<3.0.0)
Requires-Dist: google-auth-httplib2 (>=0.1.0,<0.2.0)
Requires-Dist: google-auth-oauthlib (>=0.4.6,<0.5.0)
Requires-Dist: markdown (>=3.4.3,<4.0.0)
Requires-Dist: python-decouple (>=3.5,<4.0)
Description-Content-Type: text/markdown

# Gmail Drafter: Create Mail Merge Drafts

Simple tool to take a CSV and a template and create drafts in your Gmail. Useful for sending emails to large-ish numbers
of people where you want to slightly customize the emails for each user. You can quickly run through drafts, customize it, and send.

## Installation

```shell
pip install gmail-draft-creator
```

## Usage

```shell
Usage: gmail-draft-creator [OPTIONS]

Options:
  --csv PATH       Path to the CSV file.  [required]
  --template PATH  Path to the template file.  [required]
  --subject TEXT   Subject for the email drafts.  [required]
  --dry-run        Run script without creating drafts.
  --help           Show this message and exit.

```

You can also import the `create_draft` function and use it in your own scripts.

### Template Files

You can include subject line and variables in the template file:

```text
Subject: Hello $NAME

Hi, here's another ${REASON} why I'm emailing you.
```

## Setup

### Generating a Gmail API Token

1. Navigate to the Google Cloud Console. https://console.developers.google.com/
2. Create a new project or select an existing one.
3. Go to "APIs & Services" -> "Library" and enable the Gmail API.
4. Navigate to "APIs & Services" -> "Credentials".
5. Click "Create Credentials" -> "OAuth client ID".
6. Select "Desktop app" as the application type, then click "Create".
7. Download the JSON file, rename it to `credentials.json`, and place it in the root of your project.
8. Run the script and oauth into your account

#### Credential Scopes Needed

* https://www.googleapis.com/auth/gmail.compose
* https://www.googleapis.com/auth/gmail.readonly
* https://www.googleapis.com/auth/calendar.readonly
* https://www.googleapis.com/auth/calendar.event

Some of these are in place for possible future improvements.

## TODO

- [ ] add credentials as a command line argument
- [ ] add serialized token as a CLI argument
