Export Gmail emails to Excel
Connection settings, credentials and the limits that break exports — for Gmail.
Connection settings
| Setting | Value |
|---|---|
| IMAP host | imap.gmail.com |
| Port | 993 |
| Encryption | SSL/TLS |
| Access | read-only |
Credentials
- 1. Enable 2-Step Verification
- 2. Create an App Password for Mail
- 3. Use the 16-character password with imap.gmail.com:993 SSL
Limits to expect
- Labels are not folders: one message can appear in several labels
- OAuth is mandatory when a Workspace admin disables app passwords
- Large attachments may be split into parts
Export command
python mail_to_excel.py --host imap.gmail.com --port 993 --user you@example.com --days 31 --out mail.xlsx
Next step
The universal IMAP guide · Exports by role · Ready script ($3)
FAQ
Why does my normal password fail?
Google blocks basic auth for IMAP; you need an app password or OAuth.
How do I avoid duplicate rows?
Export a single label instead of All Mail.
Related guides
- Universal IMAP exportThe method that works for every provider.
- Exports by roleColumns and pitfalls for 20 professions.