My ultimate goal is to export thousands of emails from Outlook 2007 in a format that will allow me to post them on my WordPress powered website.

Update: this problem requires multiple steps to solve, but the major stumbling block I have is that I cannot find a method for removing MicroSoft's crappy HTML from thousands odfemails in bulk.

However, I do not expect that one tool will do the job. A major obstacle right now is to find a way to export thousands of emails in a format that I can manipulate.

Since we all have an idea what the starting data file looks like (Outlook), view this page to see what the end product might look like.

There are many excellent ways to import data into WordPress. I have used Really Simple CSV Importer multiple times and it should do what I need.

There are many tools for exporting email messages, but I have not found one that works for all of my messages. In Outlook, there is an export feature but the file formats are all unacceptable.

One of the best tools is a macro (set of macros, actually) that can export all of the data I need, but it has some issues. The macro can easily export plain text messages or convert HTML messages to plain text, but when exporting HTML messages as HTML, the message has all of Microsoft's garbage HTML in it. The extra HTML elements and properties conflict with my website markup, so I cannot use the macro directly. I have tried modifying it, but I have failed.

Interestingly, WordPress is quite good at cleaning Microsoft's junk HTML. However, I only know how to trigger that function by pasting the text into the "visual editor" of WordPress. Obviously, I cannot do that for thousands of emails.

I have tried some off the shelf software, but they all have limitations that I cannot overcome. As above, a major problem is that the exported email preserves Microsoft's crappy HTML. Sometimes the problem is that the body is well-exported but the To, From, Subject, and Date fields are missing.

A last hurdle, and an important one, is cost. I am unemployed, so I cannot afford the US$249 price tag that some of the products have. Free is best, of course, but if a product were truly fantastic, then I could probably afford $20.

Thank you for your time.

  • where is the data stored, online or offline (exchange server or off-line storage table file or somewhere else)?
    – n611x007
    Commented Jan 8, 2015 at 18:02
  • what version of outlook do you use here?
    – n611x007
    Commented Jan 8, 2015 at 18:07
  • offline (.pst) Outlook 2007. Commented Jan 8, 2015 at 18:46
  • very well, check out my answer, I hope it helps you!
    – n611x007
    Commented Jan 8, 2015 at 19:05

2 Answers 2


With the free and open-source libpff I could export all the data in my outlook, I hope this helps you too:

If you have set up outlook to cache every message locally, you could export the data from the off-line storage table or .ost file which should be somewhere in C:\Users\<your_user>\AppData\Local\Microsoft\Outlook\ with a project called libpff.

For ones with programming skills, the build instructions for cygwin just worked for me. However,

For those who just want the executable program, here is my libpff build to the rescue.

The zip contains two command line programs pffexport and pffinfo.

The help pffexport --help gives a pretty straightforward idea (well done authors!).

I used the following command - replace my_user with your filename as always:

pffexport.exe -f all -m all my_user.ost

This converts the email data available on your computer into normal folders and files, like Message.html.

For example, one mail in my test export was found as the my_user.ost.export\Root - Mailbox\IPM_SUBTREE\Inbox\Message00303\Message.html file, along with other metadata files like InternetHeaders.txt or Recipients.txt.

I hope this helps you since this seems to go as close to the actual data as you can get from the offline file. All credit goes to the libpff authors for this awesome library!

For reference, I used Outlook 2010.

  • The scripts look useful and would certainly reduce the amount of time I would need to implement them. It's not clear to me if the scripts also clean out the unusual HTML that Microsoft inserts into HTML messages. Commented Jan 10, 2015 at 9:48
  • @HunterHogan oh very kind of you! Sorry I was trying to find the time to look on the data to determine the answer. (I expect it to be a sad answer, but who knows! Expecting that, I planned to check if there is a dedicated tag stripper...)
    – n611x007
    Commented Jan 15, 2015 at 13:44
  • The libpff writes only partial headers after around 200 emails. Any reason for this? Commented Nov 16, 2017 at 6:38

You can use python and the python win32 library you can access the contents of your outlook folders, including the content of messages and separately the to, from and subject fields, and then massage the content into whatever format you need. The python URL and/or Mechanise libraries can even post the content to web sites for you.

Given that you already have Outlook everything else is free, an example script from testingreflections:

#!/usr/bin/env python

from win32com.client import Dispatch

session = Dispatch("MAPI.session")
session.Logon('OUTLOOK')  # MAPI profile name
inbox = session.Inbox

print "Inbox name is:", inbox.Name
print "Number of messages:", inbox.Messages.Count

for i in range(inbox.Messages.Count):
    message = inbox.Messages.Item(i + 1)
    print message.Subject
  • 1
    Thank you for the answer and the example! I should learn Python because it keeps coming up as a useful tool. Is there a library to clean out Microsoft's unnecessary HTML? If so, then I think this is a great solution. As an example of their crazy markup, instead of just using <li> for line item, then will put <li value="1" class="Some-Stupid-Class">. Even HTMLTidy cannot clean all of their junk. Commented Dec 26, 2014 at 19:47
  • Most emails come as a text format - a little rough but no mess as well the the html/rtf/whatever format - you can actually pick which to grab. Alternatively there are a couple of tools that you could run the html through that would get rid of the MS crud. e.g. parse as XML then output as html would probably do the job. Commented Dec 26, 2014 at 20:14
  • Can the script extract Internet Headers? Commented Nov 16, 2017 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.