recipe-save-email-attachments
googleworkspace/cli
Find Gmail messages with attachments and save them to a Google Drive folder.
What is recipe-save-email-attachments?
This recipe automates the process of locating emails with attachments in Gmail and transferring those attachments to a designated Google Drive folder. Use it to organize email attachments, archive important documents, or consolidate files from specific senders.
- Search Gmail for messages matching custom criteria (e.g., from specific senders, with attachments)
- Retrieve full message details including attachment metadata
- Download attachments from Gmail messages
- Upload attachments directly to a Google Drive folder
How to install recipe-save-email-attachments
npx skills add null --skill recipe-save-email-attachments- gws-gmail skill installed
- gws-drive skill installed
- Google Workspace CLI (gws) configured with appropriate Gmail and Drive permissions
How to use recipe-save-email-attachments
- 1.Search for emails with attachments using a Gmail query (e.g., from a specific sender or with certain keywords)
- 2.Retrieve the message ID and attachment ID from the search results
- 3.Download the attachment using the Gmail API
- 4.Upload the downloaded file to your target Google Drive folder using the folder ID
Use cases
- Archive all attachments from a client email address to a shared Drive folder
- Automatically organize invoices or receipts sent via email into Drive
- Consolidate contract PDFs from multiple email threads into a single folder
- Back up important email attachments to cloud storage
- Administrative professionals managing email workflows
- Teams needing centralized document storage from email
- Anyone automating attachment organization across Gmail and Drive
recipe-save-email-attachments FAQ
Any valid Gmail search operator works, such as 'has:attachment', 'from:sender@example.com', 'before:2024-01-01', or combinations like 'has:attachment from:client@example.com'.
Open the folder in Google Drive and copy the ID from the URL (the long alphanumeric string after /folders/).
Gmail search doesn't filter by file type directly, but you can use the query to narrow by sender or date, then manually filter results or process specific attachment types after download.
Yes, you need to iterate through each attachment ID in a message and download/upload them individually.
Your Google account needs read access to Gmail messages and write access to the target Google Drive folder.
Full instructions (SKILL.md)
Source of truth, from googleworkspace/cli.
name: recipe-save-email-attachments description: "Find Gmail messages with attachments and save them to a Google Drive folder." metadata: version: 0.22.5 openclaw: category: "recipe" domain: "productivity" requires: bins: - gws skills: - gws-gmail - gws-drive
Save Gmail Attachments to Google Drive
PREREQUISITE: Load the following skills to execute this recipe:
gws-gmail,gws-drive
Find Gmail messages with attachments and save them to a Google Drive folder.
Steps
- Search for emails with attachments:
gws gmail users messages list --params '{"userId": "me", "q": "has:attachment from:client@example.com"}' --format table - Get message details:
gws gmail users messages get --params '{"userId": "me", "id": "MESSAGE_ID"}' - Download attachment:
gws gmail users messages attachments get --params '{"userId": "me", "messageId": "MESSAGE_ID", "id": "ATTACHMENT_ID"}' - Upload to Drive folder:
gws drive +upload --file ./attachment.pdf --parent FOLDER_ID
Related skills
More from googleworkspace/cli and the wider catalog.
gws-gmail
Send, read, and manage Gmail emails via Google Workspace CLI.
gws-drive
Manage Google Drive files, folders, and shared drives via CLI.
gws-docs
Read and write Google Docs via command line.
gws-calendar
Manage Google Calendar events, calendars, and access control via CLI.
gws-sheets
Read and write Google Sheets spreadsheets via CLI.
gws-gmail-send
Send emails via Gmail with attachments, CC/BCC, HTML support, and draft options.