# Gmail Inbox Analyzer A Go script to fetch sender and subject information from your Gmail inbox for organization purposes. ## Setup 1. Go to [Google Cloud Console](https://console.cloud.google.com/) 2. Create a new project or select an existing one 3. Enable the Gmail API 4. Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client IDs" 5. Choose "Desktop application" 6. Note down your Client ID and Client Secret ## Usage ```bash go mod tidy go run main.go ``` ### Authentication Flow 1. The script will display a URL 2. Visit the URL in your browser and log into your Google account 3. Copy the authorization code from the browser 4. 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 ```bash 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: ```bash 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: ```bash 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: ```bash 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: ```bash 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 ```bash # 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