Python MAPI

vasudevram vasudevram at
Fri Jul 20 20:48:57 CEST 2007

On Jul 20, 10:57 pm, kyoso... at wrote:
> Hi,
> I've been googling all over and can't find any good answers about this
> problem. I would like to create some kind of MAPI interface with
> Python such that when I open Microsoft Word (or another Office
> program) and click File, Send To, Mail Recipient it opens a program I
> wrote in Python and uses it to send the email rather than Outlook.
> The closest I've come is finding the registry key HKLM\Software\Clients
> \Mail which seems to control the default email client. I did figure
> out how to redirect mailto directives on websites to my program
> successfully, but this is a whole 'nother ballgame.
> Any suggestions are welcome. I am considering writing some VBA hooks
> in Office Apps in question, but would prefer to avoid that.
> Thanks!
> Mike
> P.S. Currently using Python 2.4, wxPython 2.8.3 (for GUI) on Windows
> XP Pro.


1: I don't know much about Windows APIs, but am currently reading the
"Windows Internals" book. Got this idea from it:

Go to
and check out the SysInternals utilities there. The book says that you
can use some of them to "spy" on what an app is doing - what registry
keys it is reading/writing, lots of other OS-level calls it makes as
it runs. Digging around and using some of these utilities to check out
what an Office app does when you use it to send mail, might help you
figure out a way to do what you want.

2. Try looking for registry entries specific to Office Apps, and look
under those subtrees for likely email-related entries to modify (if
you haven't tried that already). I guess you already know that
fiddling with the registry can be risky and can crash your system, so
take backups, etc.

Using COM via Python may also help - again, some digging required. You
probably already have the PyWin32 Python extensions for Windows COM
(earlier called win32all - see -
if not, its available here:
(scroll down the page for the link)

Vasudev Ram

More information about the Python-list mailing list