A Python tool to automatically send emails with attachments and clipboard content using the Gmail API.
- Sends all files from a specified folder as email attachments
- Automatically attaches images from the clipboard (e.g., screenshots)
- Includes clipboard text in the email body
- Uses OAuth2 for secure Gmail authentication
- Python 3.7+
- Google API client libraries (
google-auth-oauthlib,google-api-python-client) pyperclip,Pillow
git clone https://github.com/leesihun/Gmail-Autosend.git
cd Gmail-Autosendpip install google-auth-oauthlib google-api-python-client pyperclip Pillow- Go to the Google Cloud Console
- Click "Select a project" → "New Project"
- Enter a project name (e.g., "Gmail Autosend") and click "Create"
- In the Google Cloud Console, go to "APIs & Services" → "Library"
- Search for "Gmail API" and click on it
- Click "Enable"
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- If prompted, configure the OAuth consent screen:
- Choose "External" user type
- Fill in required fields (App name, User support email, Developer contact)
- Add your email to "Test users" if in testing mode
- For Application type, select "Desktop application"
- Give it a name (e.g., "Gmail Autosend Client")
- Click "Create"
- Download the JSON file and rename it to
credentials.json - Place
credentials.jsonin the project root directory
- Edit the recipient email in
gmail_automation.py(line 75):to = "[email protected]" # Change this to your target email
- Optionally, change the folder path (line 62):
FOLDER_PATH = r'./item' # Change this to your desired folder
- Place files you want to send in the
item/folder - Copy any image or text to your clipboard (optional)
- Run the script:
python gmail_automation.py
- Download
gmail_automation.exefrom the repository - Place your
credentials.jsonin the same folder as the executable - Create an
item/folder and place files you want to send - Double-click
gmail_automation.exeto run
- The first time you run the script, it will:
- Open a browser window for Google authentication
- Ask you to sign in to your Google account
- Request permission to send emails via Gmail
- Create a
token.jsonfile for future use
- Subsequent runs will use the saved
token.jsonand won't require browser authentication
Gmail-Autosend/
├── gmail_automation.py # Main Python script
├── gmail_automation.exe # Pre-built executable
├── credentials.json # Your Google API credentials (create this)
├── token.json # Auto-generated after first auth (don't share)
├── item/ # Folder containing files to send
│ ├── file1.pdf
│ ├── image.png
│ └── ...
└── README.md
- Never share your
credentials.jsonortoken.jsonfiles - These files contain sensitive authentication information
- The repository excludes these files via
.gitignorefor security - If you suspect your credentials are compromised, revoke them in Google Cloud Console
- "File not found" error: Ensure
credentials.jsonis in the same directory as the script - "Access denied" error: Check that Gmail API is enabled and OAuth consent screen is configured
- "Invalid credentials" error: Re-download
credentials.jsonfrom Google Cloud Console - "Token expired" error: Delete
token.jsonand run the script again to re-authenticate
MIT License