Export Outlook emails to Excel
Outlook has three exits: IMAP, a VBA macro inside Outlook, or PST export plus parsing. Each has a catch.
Option 1 — IMAP (works for Microsoft 365, Outlook.com and corporate)
Microsoft disabled basic auth for many tenants; app passwords still work for personal accounts with 2FA, while corporate accounts often need OAuth.
imap = imaplib.IMAP4_SSL("outlook.office365.com", 993)
imap.login("you@company.com", "app-password-or-oauth-token")
imap.select("INBOX", readonly=True)
Pros: no files to parse, works with any mailbox. Cons: OAuth setup on corporate tenants.
Option 2 — VBA macro (fast, but brittle)
Outlook can write its own table to Excel via VBA. It is fine for a few hundred messages.
Sub ExportInbox()
Dim ns As Namespace: Set ns = Application.GetNamespace("MAPI")
Dim inbox As Folder: Set inbox = ns.GetDefaultFolder(olFolderInbox)
Dim xl As Object: Set xl = CreateObject("Excel.Application")
xl.Visible = True: xl.Workbooks.Add
Dim i As Long: i = 1
Dim item As Object
For Each item In inbox.Items
xl.Cells(i, 1) = item.ReceivedTime
xl.Cells(i, 2) = item.SenderName
xl.Cells(i, 3) = item.Subject
i = i + 1
Next
End Sub
Limits: slow on large folders, macro security policies, no attachment handling, and it stops if Outlook is closed.
Option 3 — PST export + parser
File → Open & Export → Import/Export → Export to a file → Outlook Data File (.pst). Then parse the PST with a library (e.g. libpff).
Best for archives and legal holds, worst for a quick spreadsheet.
Which one to pick
| Need | Method |
|---|---|
| Weekly report of new emails | IMAP script (scheduled) |
| One-off 200 messages | VBA macro |
| Full mailbox archive | PST + parser |
| Attachments to a folder | IMAP script or dedicated extractor |
FAQ
Can I export Outlook emails to Excel with a built-in function?
No. Outlook can export to PST/CSV for contacts, but not a proper email spreadsheet. You need a macro, IMAP, or PST parsing.
Does the VBA macro work in the new Outlook?
The new Outlook for Windows has limited VBA support. Classic Outlook and Microsoft 365 desktop apps support it.
How do I handle attachments?
Neither VBA nor PST export extracts attachments conveniently. Use IMAP and save parts with a filename, or a dedicated attachment extractor.
Related guides
- IMAP → Excel for any providerThe universal method behind all Outlook exports.
- Extract attachmentsSave invoices and PDFs from any mailbox.