Export Outlook From, To, Subject, Receive Date and other meta data into Excel

By | January 18, 2017 | 70 Comments
Category: MS Excel Tags: , ,

I had a need to export all the emails’ meta data like From, To, Subject, Receive Date from Outlook. Quickly searching on the internet, I found the script at http://superuser.com/questions/816289/exporting-attachment-file-name-email-metadata-from-outlook-to-excel so I quickly created a spreadsheet and exported all the needed information.

I have made following modification to the code

  • Commented out exporting email body data as I don’t need it (if you want email body, follow the steps given at the bottom)
  • Error thrown when setting up the auto filter

Other than that code worked fine for my need.

Here are the steps

  1. Download the Macro enabled Excel spreadsheet
  2. If you see the security warning, click on “Enable Macro” button for this spreadsheet to work
  3. You will see the spreadsheet with two tabs. The first tab contains a button. Second tab contains the result.
  4. Click on the “Get Outlook Data” button
  5. It will prompt the user to select the Outlook folder/subfolder from which you want to export the data.
  6. Select the appropriate folder and click “OK”.
  7. Once completed, it will show the message “Completed” and you will get all the data that you need in the “Outlook Results” tab


How to get Email body?

Based on Richard’s comment, I thought it is a good idea to show how to get Email body. Here are the steps.

  1. If the Developer tab is not available in Excel, go to File > Options > Customize Ribbon > Developer > Check it and click OK button
    Excel customize ribbon add developer tab
  2. Now go to Developer tab > Visual Basic
    Excel developer tab visual basic button
  3. On left hand side, double click on “Module1” and on the right hand side, search for the code which is highlighted in the image below
    Uncomment vba code
  4. Remove the single quote character that is in the beginning of the line.
  5. Close this main window
  6. Save the Excel spreadsheet
  7. Close the spreadsheet
  8. Open the spreadsheet again and now you can extract first 900 characters of Email body. If you want more, change this limit within the code in the same line.


About Vishal Monpara

Vishal Monpara is a full stack Solution Developer/Architect with 13 years of experience primarily using Microsoft stack. He is currently working in Retail industry and moving 1's and 0's from geographically dispersed hard disks to geographically dispersed user leveraging geographically dispersed team members.

70 thoughts on “Export Outlook From, To, Subject, Receive Date and other meta data into Excel

  1. Peter

    Hi Vishal,

    Nice tool, is there a way the tool includes directly all subfolders as well?

  2. Vishal Monpara Post author

    Hello ES,

    The code already exists in Excel but it is commented so it does not have any effect. Follow the steps given under “How to get Email body?” within this same blog post to get the body text from outlook.

    Thank you
    Vishal Monpara

  3. Mohammad Nurihan Bin Salikin

    Hi Vishal Monpara,

    Thanks, it works!

  4. Vishal Monpara Post author

    Hello Jose,

    You can always hardcode the value of “strFolderName” in that line so it will not show the window to pick the folder name.

    Vishal Monpara

  5. Jose Luis Romero rayan

    I have downloaded your code and works fine, however Is there any way to substitue : Set strFolderName = objNamespace.PickFolder, by some sentences?
    The point is that I need to check the names of the attachments files from a vba macro, without picking the folder.
    I have been exploring the web and I am not able to find out a solution.
    Thank uoy very much in advance.

  6. Vishal Monpara Post author

    Hello Michael,

    You may use the following logic to make it work.

    1. You need to get the email only for a certain date range. Date range must not overlap when you run the program on multiple days. This ensures that you are getting only those emails which has never been fetched previously.
    2. Before you start fetching the email, make the start position as the last cell of Excel content

    Vishal Monpara

  7. Michael

    How would i be able to adapt the code so that new emails will just add to the excel file not replace it?


  8. Vishal Monpara

    Hi Von,

    Yes it is possible. If you or your team can code in VBA, you can create a separate form to get date range and use that date range to filter the messages.

    Vishal Monpara

Leave a Reply

Your email address will not be published. Required fields are marked *