Outlook Export Script/ Macro

Before using the macro below please accept that you do so at your own risk.

Also please read the note at the top of the Macro about using it with Outlook 2007/ 2010 (see below and the top of the Macro).

If there are any bugs with this macro, or if you have any other feedback, please contact me using the comment form (below); if you do not want your comment published please say (also remember that if I have previously approved a comment by you next one will automatically be approved).

Also if you have any suggested features I am happy to consider them, but, I have had some nasty messages from people who want me to add specific features and want them added right away. Please before contacting me remember I am providing my work free of charge and I am a busy professional engineer and a father.

Also please accept those reasons as an excuse (and an apology) for the infrequent updates to this page.

With regard to paid work please contact my employer directly (more information can be found on my LinkedIn profile, icon above).

Outlook Export Script



Changes since last version

  • File names are now shorter with a shorter date format – this is to reduce the instances of file permission errors when saving on NTFS based file systems (the error still occurs occasionally, usually when saving RSS feeds – it’s due to naming limitations with the NTFS file system that I have no control over)
  • RSS/ News feed items are now exported correctly (no longer saved as “UNKNOWN CLASS 45″)


This is one of the most popular items on my site. Version 2.3 (December 2011) of my Outlook archive visual basic macro can be downloaded from the link above as a text file, to use open the visual basic editor in Outlook and paste in the code.

There are some instructions at the top of the script and you will have to follow them to set up the directory you wish to export to and if you wish to have the macro ask for a folder to export, or ask for the top level folder.

This version has been updated to work with Outlook 2007 and 2010 (please read the instructions on adding runtime libraries at the top of the Macro).

Once done run the new macro that has appeared in your list of available macro’s. Please note I do not know how this macro will react to other macro’s, and as always please test first on data you have backed up.

This free Macro does the following:

  • Automatically Exports all standard Outlook objects (email, contact, calendar entry, read receipt etc) to a user configurable location , proprietary objects (e.g. a special company forms) are not supported, but may be exported anyway in a text only format.
  • Retains folder structure.
  • Saves Emails as HTML with an index number
  • Supports backup of RSS feeds (this can be very slow, depending on how many subscriptions etc you have)
  • Extracts attachments, saves with same index number as the email and adds notification and link to the original email
  • Saves Calendar entries as both text and .ICS
  • Saves Contacts as both text and .VCF
  • Saves all other objects as text only, with index number
  • Extracts any attachments from non-email objects and saves each attachment with the same index number as the object. A notification is added to the object.


This macro will not work if you have a folder in Outlook called ‘Attachments’, which is the name of the default folder that attachments are saved in (as a sub-folder of the one which the email etc is saved in), just give any folder with that name a temporary name like ‘Attachments1′ or the script will do odd things.

The Macro gives no error messages, no status update, and it will reduce Outlook’s performance to almost zero whilst it runs; so depending on how full your Outlook folders are you may be waiting a long time. You can either go to lunch, or for a little entertainment go to the folder you entered as ‘Path’, you should see a slowly growing folder list, and within each folder a growing number of HTML and text files. If you don’t see this then something went wrong (e.g. folder path incorrect), check that you entered your user options correctly.

You may also find problems with the file names and permissions of the exported files. Errors can include missing ends of file names and access denied messages, this is due to the limitations of NTFS filesystems and not a fault with the macro. For those of you using Linux I would consider using an Ext3 partition mounted under Windows with the Ext2Ifs driver to export to, particularly if you have a complex series of nested folders.

As with my earlier Outlook macro (no longer available) the reasoning behind writing this is to support the archiving of Outlook contents into something that can be viewed on any platform (primarily Linux) and indexed by free off the shelf indexing software (such as the now defunct Google Desktop, Beagle or Copernic Desktop Search).

If you are using Windows search this macro is a useful way of extracting old emails in a format that can be indexed by Windows without you having to keep giant PST files going back a decade or more associated with Outlook.

There are now other alternatives available to Linux users, and I welcome discussion of those options below (please note, as mentioned, this is a moderated blog).

Bugs in Outlook 2007 and 2010

In both Outlook 2007 and 2010 the macro can hang and Outlook can be come totally unresponsive; this can happen at any time and is caused when the macro struggles to communicate with the exchange/ imap etc server (I have not noticed this when using POP), it can also happen when backing up from PST files (associated with an exchange account) as some information is still downloaded from the server.

The only advice I can give is to make sure you have a good link to your server (e.g. try this at work after everyone has gone home), or try using the macro with Outlook working offline.

Please note this error is intermittent and usually fixes itself within a minute or so.


  • Martian
    #1 written by Martian  5 years ago


    This is very very nice and useful script! Thank you very much for spreading it around! :) I would like to suggest one improvement. Would you consider to make the script to replace the not supported by NTFS driver characters of file name with something else like underscore etc.

    In additional I have huge amount of messages all containing # in the subject and I notice that all directories that the macro creates are cut upon reaching this symbol. As I tested this is not denied symbol for file name in NTFS?


    • Ed
      #2 written by Ed  5 years ago

      Hi Martin,

      I will take a look at the script; it has been a while since I wrote it (and it may take some time to get round to looking at it – sorry). I thought I’d written a sub-routine or something to find all the problem characters but might have missed that one. I will also look at it for putting in an underscore.

      Kind regards,


  • JimD
    #4 written by JimD  5 years ago

    I tried an older version and new version of your code (which used to work well for me) and now every .html file is all Chinese characters and the associated files (which used to be images) consists of colorschememapping.xml, filelist.xml, and themedata.thmx and nothing else (no images). Is something off with this version? I have tried 2 different machines and have replicated the same results. :/

    • Ed
      #5 written by Ed  5 years ago

      I have no idea what that is about. I did have some problems when switching to Outlook 2010, but nothing like that. Do you have any special settings for saving files, or are you using a special template for your emails?

      • Ed
        #6 written by Ed  5 years ago

        Hi Jim, the 403 error you got was caused by my over zealous security software, I think I have fixed it now. With regard to the error have you included The Microsoft Office Runtime V1.0 Type Library? To use open references from the tools menu (in VB editor), scroll down and select.

  • Add Comment Register
    You may use these HTML tags: <a> <abbr> <acronym> <b> <blockquote> <cite> <code> <del> <em> <i> <q> <strike> <strong>

  • Comment Feed for this Post
Go to Top