Export Insurance broker emails to Excel
Four steps, one command, and a completeness check at the end — for policy documents and renewals from email.
Step 1 — connect read-only
Use an app password, never the main password. The script opens the folder in read-only mode, so nothing is marked as read or deleted.
python mail_to_excel.py --host imap.example.com --user you@example.com --days 31 --fields policy,client,renewal,premium,status --out insurance-broker.xlsx
Step 2 — filter to one period
A month or a quarter, not «everything». Renewals fail silently. A table of policy numbers and dates turns renewals into a calendar instead of a memory test.
Step 3 — keep only the columns that matter
| Column | Why it matters |
|---|---|
policy | Policy number — the key for renewals. |
client | The join key for every other report you will build later. |
renewal | Renewal date; the column that becomes your calendar. |
premium | Premium amount with currency and period columns. |
status | Fixed vocabulary: open / in progress / done / blocked. |
Step 4 — verify completeness
- Run the same search in your mail client and note the message count.
- Compare it with the row count in the spreadsheet.
- If the numbers differ, the filter or the folder is wrong — fix it before using the file.
Example output
| policy | client | renewal | premium | status |
|---|---|---|---|---|
| POL-99321 | Orion Ltd | 2026-12-01 | 2,400 | quoted |
Pitfalls
- Scanned policy PDFs are not searchable — Keep the file reference and mark «scan» so OCR can be added later.
- Premium values mix currencies and periods — Separate currency and period columns; never sum across them.
Provider notes
Corporate Exchange typically requires OAuth; personal Outlook works with an app password.
FAQ
Can this remind me about renewals?
Export weekly and sort by renewal date; the spreadsheet becomes the reminder list.
Does it read policy numbers from PDFs?
Not yet — it indexes the attachments; extraction from PDF text is a separate step.
How many messages can it handle?
Thousands per run with a date filter; very large mailboxes are better exported month by month.
Will it change anything in the mailbox?
No. Read-only access is the default and should stay enabled.
Related guides
- Insurance broker: columns and pitfallsThe compact overview for this role.
- Universal IMAP guideApp passwords, decoding and Excel output.