2.8 KiB
2.8 KiB
Gmail Inbox Analyzer
A Go script to fetch sender and subject information from your Gmail inbox for organization purposes.
Setup
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API
- Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs"
- Choose "Desktop application"
- Note down your Client ID and Client Secret
Usage
go mod tidy
go run main.go <CLIENT_ID> <CLIENT_SECRET> <csv|json>
Authentication Flow
- The script will display a URL
- Visit the URL in your browser and log into your Google account
- Copy the authorization code from the browser
- Paste it back into the terminal
Output Formats
- CSV:
go run main.go CLIENT_ID CLIENT_SECRET csv > emails.csv - JSON:
go run main.go CLIENT_ID CLIENT_SECRET json > emails.json
Example
go run main.go "123456789-abc.apps.googleusercontent.com" "GOCSPX-your_secret" csv > my_emails.csv
The script fetches all emails from your inbox with:
- Sender email address
- Subject line
- Date
- Message ID
No credentials are stored locally - authentication is required each time you run the script.
Organization Tools
After exporting your email data, use these additional tools to organize your inbox:
1. Email Analysis
Analyze patterns in your exported data:
go run analyze.go emails.csv summary
go run analyze.go emails.csv json > analysis.json
2. Gmail Filter Generator
Generate Gmail filters based on your email patterns:
go run filters.go analysis.json filters # Show filter suggestions
go run filters.go analysis.json queries # Show search queries
go run filters.go analysis.json all # Show everything
3. Cleanup Recommendations
Get specific cleanup recommendations:
go run cleanup.go analysis.json summary # Quick overview
go run cleanup.go analysis.json detailed # Full instructions
4. Interactive Organization Wizard
Run the complete organization workflow:
go run organize.go emails.csv
This will guide you through:
- Email analysis
- Organization approach selection (aggressive cleanup, filters-focused, balanced, or analysis-only)
- Step-by-step implementation
Workflow Example
# 1. Export your Gmail data
go run main.go "your-client-id" "your-secret" csv > emails.csv
# 2. Run the organization wizard
go run organize.go emails.csv
# 3. Follow the interactive prompts to organize your inbox
The tools will help you:
- Identify top senders and domains
- Detect email patterns (newsletters, promotions, etc.)
- Generate Gmail filters for automatic organization
- Find emails safe to delete or archive
- Create unsubscribe recommendations
- Provide specific Gmail search queries for cleanup