Skip to main content

Kutools for Office β€” One Suite. Five Tools. Get More Done.

How to export emails from Outlook to Excel automatically?

Author Xiaoyang Last modified

Normally, you can export emails from Outlook to Excel using the Import/Export feature. However, if you need to automatically export incoming emails to an Excel file as they arrive, Outlook does not provide a built-in solution. This article introduces two methods to accomplish this:

Automatically Export New Incoming Emails from the Inbox to Excel Using VBA (Manual & Tedious)

Quickly Export All Emails from a Selected Folder to an Excel Report with Kutools for Outlook πŸ‘ (Fast & Easy)


Automatically Export New Incoming Emails from the Inbox to Excel Using VBA

If you need an automated way to export new emails to Excel, you can use the following VBA code. This method monitors the Inbox folder and exports new email details to an Excel file as soon as they arrive.

Step 1: Prepare the Excel File

Before executing the VBA code, set up an Excel workbook to store the exported email data. In the first row, include the following column headers: No., Sender Name, Sender Email Address, Subject, and Received Time.

doc auto export emails to excel 1

Step 2: Open the VBA Editor in Outlook

1. Press Alt + F11 to open the Microsoft Visual Basic for Applications window.

2. In the Project1 (VbaProject.OTM) pane, expand Microsoft Outlook Objects and double-click ThisOutlookSession.

Step 3: Insert the VBA Code

Copy and paste the following VBA code into the module:

Public WithEvents GMailItems As Outlook.Items
Private Sub Application_Startup()
    Set GMailItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub GMailItems_ItemAdd(ByVal Item As Object)
    Dim xMailItem As Outlook.MailItem
    Dim xExcelFile As String
    Dim xExcelApp As Excel.Application
    Dim xWb As Excel.Workbook
    Dim xWs As Excel.Worksheet
    Dim xNextEmptyRow As Integer
    On Error Resume Next
    If Item.Class <> olMail Then Exit Sub
    Set xMailItem = Item
    ' Update this path with your actual Excel file path  
    xExcelFile = "C:\Users\DT168\Desktop\split document\kto-data.xlsx"
    If IsWorkBookOpen(xExcelFile) = True Then
        Set xExcelApp = GetObject(, "Excel.Application")
        Set xWb = GetObject(xExcelFile)
        If Not xWb Is Nothing Then xWb.Close True
    Else
        Set xExcelApp = New Excel.Application
    End If
    Set xWb = xExcelApp.Workbooks.Open(xExcelFile)
    Set xWs = xWb.Sheets(1)
    xNextEmptyRow = xWs.Range("B" & xWs.Rows.Count).End(xlUp).Row + 1
    With xWs
        .Cells(xNextEmptyRow, 1) = xNextEmptyRow - 1
        .Cells(xNextEmptyRow, 2) = xMailItem.SenderName
        .Cells(xNextEmptyRow, 3) = xMailItem.SenderEmailAddress
        .Cells(xNextEmptyRow, 4) = xMailItem.Subject
        .Cells(xNextEmptyRow, 5) = xMailItem.ReceivedTime
    End With
    xWs.Columns("A:E").AutoFit
    xWb.Save
End Sub
Function IsWorkBookOpen(FileName As String)
    Dim xFreeFile As Long, xErrNo As Long
    On Error Resume Next
    xFreeFile = FreeFile()
    Open FileName For Input Lock Read As #xFreeFile
    Close xFreeFile
    xErrNo = Err
    On Error GoTo 0
    Select Case xErrNo
        Case 0: IsWorkBookOpen = False
        Case 70: IsWorkBookOpen = True
        Case Else: Error xErrNo
    End Select
End Function

doc auto export emails to excel 2

⚑ Tip: In the above code, C:\Users\DT168\Desktop\split document\kto-data.xlsx represents the file path and name of the Excel workbook where the email data will be stored. Be sure to modify this path to match the actual location and file name you want to use.

Step 4: Enable Microsoft Excel Object Library

1. In the Microsoft Visual Basic for Applications window, click Tools > References.

2. In the References - Project1 dialog box, scroll down and check the Microsoft Excel Object Library option.

3. Click OK to apply changes.

doc auto export emails to excel 3

Step 5: Save and Restart Outlook

1. Save the VBA code and close the editor.

2. Restart Outlook for the changes to take effect.

Result:

From now on, every new email arriving in the Inbox will be automatically exported to the specified Excel workbook.

doc auto export emails to excel 4

Limitations of the VBA Method:

  • ❌ Works for One Inbox Only: This method only tracks new emails in the default Inbox. If you have multiple accounts, it won’t capture emails from other accounts.
  • ❌ Requires Macro-Enabled Outlook: VBA macros must be enabled for this to function, which can pose security concerns.
  • ❌ File Path Dependency: If the Excel file is moved or deleted, the code will fail.
  • ❌ Manual Setup Required: Users must manually input the Excel file path and set up the VBA environment.

πŸ“Š Smarter Email Statistics with Kutools

Easily track and analyze your email activity with Kutools for Outlook’s Statistics feature. Now count received emails by day, week, or month, and view results in clear, professional charts! Streamline your email management and gain valuable insights with just a few clicks.

shot of the Statistics result

Quickly Export All Emails from a Selected Folder to an Excel Report with Kutools for Outlook πŸ‘

If you need a hassle-free way to export emails from any folder (Inbox, Sent Items, Custom Folders) without using VBA, Kutools for Outlook’s Quick Report feature provides a simple solution.

Say goodbye to Outlook inefficiency! Kutools for Outlook makes batch email processing easier - now with free AI-powered features! Download Kutools for Outlook Now!!

Step 1: Select the Folder and Enable the Quick Report Feature

1. Open Outlook and navigate to the folder you want to export (Inbox, Outbox, Sent Items, etc.).

2. Click Kutools Plus > Report > Quick Report.

Step 2: Choose Save Location

1. In the Save Report window, choose a location and enter a file name for the export.

2. Click Save.

doc auto export emails to excel 7

Step 3: Open the Exported Report

A confirmation message will appear. Click Yes to open the exported file.

doc auto export emails to excel 8

Result:

All emails from the selected folder will be exported to an Excel-friendly XML file, displaying the sender, subject, received time, and more.

doc auto export emails to excel 9

Advantages of Kutools for Outlook Method:

  • βœ… Works with Any Folder: Export emails from Inbox, Sent Items, Outbox, or custom folders.
  • βœ… No VBA Required: No need to enable macros or edit code.
  • βœ… Multi-Account Support: Export emails from multiple email accounts effortlessly.
  • βœ… Time-Saving: A few clicks generate an instant report.
  • βœ… Customizable Data Export: Choose which details (subject, sender, date, etc.) to include.
Note: To apply the Quick Report utility of Kutools for Outlook, firstly, you should download and install Kutools for Outlook.

Which Method Should You Use?

Here’s a comparison of the two methods to help you decide which one best suits your needs:

MethodBest ForEase of UseEfficiency
Using VBA Code (Automated but Complex) Automatically exporting new emails from the Inbox ⭐⭐ ⭐⭐⭐⭐
Using Kutools for Outlook (Simple and Flexible) Quickly exporting all emails from a selected folder ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐⭐

By selecting the right method, you can efficiently export Outlook emails to Excel based on your workflow needs!


Related Articles

  • Export Email Body Table To Excel In Outlook
  • When you receive an Email that contains some tables in the body, sometimes, you may need to export all tables from the message body to an excel worksheet. Normally, you can copy and paste the tables to worksheet, but, here, I will talk about a useful method to solve this job when there are multiple tables needed to be exported.
  • Extract Or Export Tasks List To Excel In Outlook
  • While using Outlook, you can extract the task list to Excel for other usage. With the powerful Export feature in Outlook, you can easily export your tasks list to Excel. Please do as below tutorial shows.
  • Export Contacts’ Information With Photos In Outlook
  • When you export contacts from Outlook to a file, only the text information of the contacts can be exported. But, sometimes, you need the photos to be exported as well as the contacts’ text information, how could you deal with this task in Outlook?

Best Office Productivity Tools

Breaking News: Kutools for Outlook Launches Free Version!

Experience the all-new Kutools for Outlook with 100+ incredible features! Click to download now!

πŸ€– Kutools AI : Uses advanced AI technology to handle emails effortlessly, including replying, summarizing, optimizing, extending, translating, and composing emails.

πŸ“§ Email Automation: Auto Reply (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

πŸ“¨ Email Management: Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

πŸ“ Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

🌟 Interface Magic: 😊More Pretty and Cool Emojis   /  Remind you when important emails come  /  Minimize Outlook Instead of Closing ...

πŸ‘ One-click Wonders: Reply All with Attachments  /   Anti-Phishing Emails  /  πŸ•˜Show Sender's Time Zone ...

πŸ‘©πŸΌβ€πŸ€β€πŸ‘©πŸ» Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Instantly unlock Kutools for Outlook with a single click. Don't wait, download now and boost your efficiency!

kutools for outlook features1 kutools for outlook features2

πŸš€ One-Click Download β€” Get All Office Add-ins

Strongly Recommended: Kutools for Office (5-in-1)

One click to download five installers at once β€” Kutools for Excel, Outlook, Word, PowerPoint and Office Tab Pro. Click to download now!

  • βœ… One-click convenience: Download all five setup packages in a single action.
  • πŸš€ Ready for any Office task: Install the add-ins you need, when you need them.
  • 🧰 Included: Kutools for Excel / Kutools for Outlook / Kutools for Word / Office Tab Pro / Kutools for PowerPoint