Reading Outlook .msg file using Python

Tim Golden mail at
Mon Oct 11 17:54:53 CEST 2010

On 11/10/2010 4:39 PM, John Henry wrote:

> I am trying your code but when it get to the line:
>>     mapi.MAPIInitialize ((mapi.MAPI_INIT_VERSION, 0))
> I got the error message:
> Either there is no default mail client or the current mail client
> cannot fulfill the messsage requrest.  Please run Microsoft
> Outlook ... client.
> I have Outlook (not Express - Outlook 2002) running and I did set it
> to be the default mail client.  Does MAPI works with Exchange only?

No. I was running it with Outlook 2003 installed (not running,
in fact, although it is the default mail client on that machine).

> (And why do I need MAPI to read the file?)

Basically because the MAPI subsystem already contains all
the code to interpret that particular format of structured
storage. If you can find some source of info which tells
you how to parse the format directly, then you can sidestep
MAPI. Presumably this is what is done by the Java code you

I'm afraid I'm not at work at the moment, and I don't run
Outlook on this machine. (So I can't even save an .msg file
to test). FWIW the code did run successfully on my work
machine and produced the plain text of the email, so it
is just a configuration sort of issue. If no-one chips
in with a suggestion in a few hours, might be worth
posting to python-win32; there might be people there who
don't watch this (higher-traffic) list.

I have a vague memory that when I set this kind of thing
up to run on our Helpdesk server where I use this to
ingest incoming emails I did have to install a sort
of server-only alternative to Outlook. I'll try to remote
into the server later to see if I can spot it. But that
still wouldn't explain what the problem was if you were
actually running Outlook in any case.


More information about the Python-list mailing list