◈ Mail → Excel

Export Outlook emails to Excel

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

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

NeedMethod
Weekly report of new emailsIMAP script (scheduled)
One-off 200 messagesVBA macro
Full mailbox archivePST + parser
Attachments to a folderIMAP script or dedicated extractor
Corporate Microsoft 365 often blocks app passwords. Ask IT for an OAuth app registration, or use a local Outlook export.

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