◈ Mail → Excel

Export Lawyer emails to Excel

By the Mail → Excel team · Updated 2026-10-20

Four steps, one command, and a completeness check at the end — for client correspondence archive for matters.

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 matter,client,date,document,privilege --out lawyer.xlsx

Step 2 — filter to one period

A month or a quarter, not «everything». Matters are defined by documents and dates. An index that maps every document to a matter saves hours before a hearing.

Step 3 — keep only the columns that matter

ColumnWhy it matters
matterThe matter number is the primary key for legal correspondence.
clientThe join key for every other report you will build later.
dateMessage date in ISO 8601; sortable and unambiguous across time zones.
documentFile name of the related attachment.
privilegeMarks privileged material so it can be filtered before sharing.

Step 4 — verify completeness

  1. Run the same search in your mail client and note the message count.
  2. Compare it with the row count in the spreadsheet.
  3. If the numbers differ, the filter or the folder is wrong — fix it before using the file.

Example output

matterclientdatedocumentprivilege
2026-114Orion Ltd2026-10-12NDA_v2.pdfprivileged

Pitfalls

Provider notes

Corporate Exchange often blocks app passwords; use OAuth or an export from Outlook desktop.

Ready-made: the $3 script implements these steps and writes the Excel file with the columns above. Get the script.

FAQ

Does the export include email bodies?

By default it is metadata only. Bodies can be added, but then the file becomes privileged material and needs stricter storage.

Can I prove nothing was missed?

Keep the message count from the run next to the row count — that is your completeness check.

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