Export Support lead emails to Excel
Four steps, one command, and a completeness check at the end — for ticket-like email triage.
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 ticket,customer,severity,first_reply,resolution --out support-lead.xlsx
Step 2 — filter to one period
A month or a quarter, not «everything». First reply time is the only support metric customers feel. Email metadata gives it without a helpdesk migration.
Step 3 — keep only the columns that matter
| Column | Why it matters |
|---|---|
ticket | Ticket id if you have a helpdesk; otherwise thread id. |
customer | Customer or company name. |
severity | Fixed severity scale used by the support team. |
first_reply | Time from first inbound message to first outbound reply. |
resolution | How the ticket ended (fixed, workaround, closed). |
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
| ticket | customer | severity | first_reply | resolution |
|---|---|---|---|---|
| SUP-3310 | Acme | high | 18 min | fixed |
Pitfalls
- Duplicates when many people are in Cc — Deduplicate by thread id, not by subject.
- First reply time looks wrong — Use the first outbound message after the customer’s first inbound message.
Provider notes
Shared support mailboxes may be IMAP-accessible with your own login if the admin granted access.
FAQ
Can this replace a helpdesk?
No. It measures and exports; a helpdesk adds routing, SLAs and history.
How do I handle after-hours messages?
Add a «business hours» column in the spreadsheet rather than changing the raw timestamps.
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
- Support lead: columns and pitfallsThe compact overview for this role.
- Universal IMAP guideApp passwords, decoding and Excel output.