Loading...
Loading...
Manage Gmail messages, drafts, and labels. Send emails, search inbox, and organize email. Use when working with Gmail email management.
npx skill4agent add odyssey4me/agent-skills gmailpip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyamlpython scripts/gmail.py check~/.config/agent-skills/google.yamloauth_client:
client_id: your-client-id.apps.googleusercontent.com
client_secret: your-client-secretpython scripts/gmail.py check| Scope | Permission | Used For |
|---|---|---|
| Read messages, labels, settings | Listing and reading messages |
| Send emails | Sending messages and drafts |
| Modify labels and metadata | Managing labels on messages |
| Manage labels | Creating and listing labels |
keyring del agent-skills gmail-token-jsonpython scripts/gmail.py checkpython scripts/gmail.py checkpython scripts/gmail.py auth setup \
--client-id YOUR_CLIENT_ID \
--client-secret YOUR_CLIENT_SECRET~/.config/agent-skills/gmail.yaml# List recent messages
python scripts/gmail.py messages list
# Search for unread messages
python scripts/gmail.py messages list --query "is:unread"
# Search with max results
python scripts/gmail.py messages list --query "from:user@example.com" --max-results 20
# Output as JSON
python scripts/gmail.py messages list --query "subject:meeting" --json--query--max-results--jsonis:unreadfrom:user@example.comsubject:meetinghas:attachmentafter:2024/01/01label:important# Get full message
python scripts/gmail.py messages get MESSAGE_ID
# Get minimal format
python scripts/gmail.py messages get MESSAGE_ID --format minimal
# Output as JSON
python scripts/gmail.py messages get MESSAGE_ID --jsonmessage_id--format--json# Send simple email
python scripts/gmail.py send \
--to recipient@example.com \
--subject "Hello" \
--body "This is the message body"
# Send with CC and BCC
python scripts/gmail.py send \
--to recipient@example.com \
--subject "Team Update" \
--body "Here's the update..." \
--cc team@example.com \
--bcc boss@example.com
# Output as JSON
python scripts/gmail.py send \
--to user@example.com \
--subject "Test" \
--body "Test message" \
--json--to--subject--body--cc--bcc--json# List drafts
python scripts/gmail.py drafts list
# List with custom max results
python scripts/gmail.py drafts list --max-results 20
# Output as JSON
python scripts/gmail.py drafts list --json--max-results--json# Create draft
python scripts/gmail.py drafts create \
--to recipient@example.com \
--subject "Draft Subject" \
--body "This is a draft message"
# Create draft with CC
python scripts/gmail.py drafts create \
--to recipient@example.com \
--subject "Meeting Notes" \
--body "Notes from today's meeting..." \
--cc team@example.com
# Output as JSON
python scripts/gmail.py drafts create \
--to user@example.com \
--subject "Test Draft" \
--body "Draft body" \
--json--to--subject--body--cc--bcc--json# Send draft by ID
python scripts/gmail.py drafts send DRAFT_ID
# Output as JSON
python scripts/gmail.py drafts send DRAFT_ID --jsondraft_id--json# List labels
python scripts/gmail.py labels list
# Output as JSON
python scripts/gmail.py labels list --json--json# Create label
python scripts/gmail.py labels create "Project X"
# Output as JSON
python scripts/gmail.py labels create "Important" --jsonname--jsonpython scripts/gmail.py checkpython scripts/gmail.py messages list --query "is:unread"python scripts/gmail.py messages list --query "from:boss@example.com" --max-results 5python scripts/gmail.py send \
--to colleague@example.com \
--subject "Quick Question" \
--body "Do you have time for a meeting tomorrow?"# Create draft
python scripts/gmail.py drafts create \
--to team@example.com \
--subject "Weekly Update" \
--body "Here's this week's update..."
# List drafts to get the ID
python scripts/gmail.py drafts list
# Send the draft
python scripts/gmail.py drafts send DRAFT_ID# Create a label
python scripts/gmail.py labels create "Project Alpha"
# List all labels
python scripts/gmail.py labels list# Find emails with attachments from last week
python scripts/gmail.py messages list --query "has:attachment newer_than:7d"
# Find important emails from specific sender
python scripts/gmail.py messages list --query "from:ceo@example.com is:important"
# Find emails in a conversation
python scripts/gmail.py messages list --query "subject:project-alpha"| Operator | Description | Example |
|---|---|---|
| Sender email | |
| Recipient email | |
| Subject contains | |
| Has label | |
| Has attachment | |
| Unread messages | |
| Starred messages | |
| After date | |
| Before date | |
| Newer than period | |
| Older than period | |
OR# AND (implicit)
from:user@example.com subject:meeting
# OR
from:user@example.com OR from:other@example.com
# Grouping with parentheses
(from:user@example.com OR from:other@example.com) subject:meetingpython scripts/gmail.py check~/.config/agent-skills/google.yamlkeyring del agent-skills gmail-token-json
python scripts/gmail.py checkpip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyamlhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/gmail.labels~/.config/agent-skills/gmail.yaml