Automatically log Gmail messages to a Google Sheet based on filter rules. No Zapier, no third-party services — just Google Apps Script.
Demo: https://youtu.be/placeholder (coming soon)
Try it: Make a copy
- Define rules — Create Gmail search queries in a spreadsheet
- Auto-categorize — Automatically tag emails by keywords in subject/body
- Log to sheet — Timestamp, sender, subject, category, and direct Gmail link
- Run on schedule — Time-driven triggers check every 5–60 minutes
- Idempotent — Won't log the same email twice (uses Gmail labels for tracking)
- Free — No subscription, no limits
- Private — Your data stays in your Google account
- Flexible — Multiple filter rules, customizable fields
- Fast — Processes 100+ emails per run
Make a copy of this spreadsheet
- In your copied spreadsheet, click Extensions → Apps Script
- Delete the default
Code.gsfile - Click + next to Files → paste the contents of
Code.gsfrom this repo - Click Save (floppy disk icon)
- Click Run → select
setupTemplate - Authorize the script when prompted (click through permissions)
- Switch to the "Rules" tab and edit the sample Gmail search queries
- Switch to "Categories" and customize auto-categorization keywords
- Click 📧 Email Logger →
▶️ Run Logger Now to test - Check the "Log" tab — your emails should appear!
The logger will run automatically every 15 minutes (configurable in Settings).
| Sheet | Purpose |
|---|---|
| Settings | Polling interval, max emails, logging options |
| Rules | Gmail search queries to monitor |
| Categories | Auto-categorization keywords and priorities |
| Log | All logged emails with metadata |
| Enabled | Rule Name | Gmail Search Query | Description |
|---|---|---|---|
| Yes | Stripe Receipts | from:stripe.com subject:receipt |
Payment receipts |
| Yes | Client Emails | from:client@example.com |
Important client comms |
| No | Newsletters | label:Newsletter |
Weekly digests (disabled) |
| Category | Keywords | Priority |
|---|---|---|
| Receipts | receipt, invoice, payment, paid | 1 |
| Client | client, project, deliverable | 2 |
| Support | help, ticket, bug, issue | 3 |
Categories are checked in priority order. First match wins.
- ✅ Multiple filter rules with Gmail search syntax
- ✅ Auto-categorization by subject/body keywords
- ✅ Deduplication via Gmail labels
- ✅ Time-driven triggers (5–60 minutes)
- ✅ Direct Gmail links for each logged email
- ✅ Configurable body logging (with character limits)
- ✅ One-click template setup
- ✅ Status dashboard
Gmail's search syntax is powerful. Some examples:
| Query | Finds emails... |
|---|---|
from:stripe.com |
From Stripe |
subject:invoice |
With "invoice" in subject |
from:client.com OR from:vendor.com |
From either domain |
label:receipts -label:processed |
In Receipts label, not processed |
newer_than:1d |
Received in last 24 hours |
has:attachment filename:pdf |
With PDF attachments |
Q: Will this delete my emails?
A: No. It only reads emails and applies a "Processed" label. Original emails stay untouched.
Q: How do I stop it?
A: Click 📧 Email Logger → ⏸️ Stop Auto-Logging.
Q: Can I change the polling interval?
A: Yes — edit the "Polling Interval (minutes)" value in the Settings tab, then restart the trigger.
Q: What if I want to re-log an email?
A: Remove the "EmailLogger/Processed" label from the email in Gmail, then run the logger again.
Q: Is there a limit?
A: Google Apps Script has daily quotas (20,000 emails/day for read operations). The default max is 100 emails per run to stay within limits.
"Authorization required" keeps appearing
- This is normal for the first run. Click through all authorization prompts.
No emails appearing in Log
- Check that your Rules have "Yes" in the Enabled column
- Verify your Gmail search query works in Gmail first
- Check View → Executions in Apps Script for error messages
"Exceeded maximum execution time"
- Reduce "Max Emails Per Run" in Settings (try 50)
- Add more specific date filters to your rules (e.g.,
newer_than:7d)
- Attachment logging (link to Drive)
- Email body full-text search
- Export to CSV/Excel
- Slack/Discord notifications
- Multiple spreadsheet outputs
MIT — See LICENSE
Built by PressedCoffee as part of the Automation Tool Loop.
Found this useful? Star ⭐ the repo and share what you're building.