Export Real estate agent emails to Excel
Four steps, one command, and a completeness check at the end — for inquiries and document collection.
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 property,buyer,stage,documents,date --out real-estate-agent.xlsx
Step 2 — filter to one period
A month or a quarter, not «everything». Deals stall on missing documents, not on interest. The export shows exactly which file is missing for which buyer.
Step 3 — keep only the columns that matter
| Column | Why it matters |
|---|---|
property | Property address or listing code. |
buyer | Buyer name or id. |
stage | Pipeline stage as a fixed vocabulary, not free text. |
documents | Which documents are required and which are still missing. |
date | Message date in ISO 8601; sortable and unambiguous across time zones. |
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
| property | buyer | stage | documents | date |
|---|---|---|---|---|
| 12 Oak St | M. Rossi | viewing | ID, proof of funds | 2026-10-17 |
Pitfalls
- Large attachments slow the export — Export metadata first and download attachments in a separate pass.
- Buyer data is stored without a legal basis — Keep only what the deal requires and delete closed leads on schedule.
Provider notes
Yandex Mail requires an app password; enable IMAP in settings first.
FAQ
Can I track document completeness?
Yes — add one column per document type and mark missing ones empty.
Is this compliant with data protection?
Only with consent and a retention policy; the export is a tool, not a legal basis.
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
- Real estate agent: columns and pitfallsThe compact overview for this role.
- Universal IMAP guideApp passwords, decoding and Excel output.