473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Python MAPI

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.

Jul 20 '07 #1
8 4100
On Jul 20, 10:57 pm, kyoso...@gmail.com 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.
Hi,

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

Go to http://www.microsoft.com/technet/sys...s/default.mspx
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 http://wiki.python.org/moin/Win32All) -
if not, its available here:

http://www.python.org/download/releases/2.4.4/
(scroll down the page for the link)

Vasudev Ram
www.dancingbison.com
jugad.livejournal.com
sourceforge.net/projects/xtopdf
Jul 20 '07 #2
On Jul 20, 1:48 pm, vasudevram <vasudev...@gmail.comwrote:
On Jul 20, 10:57 pm, kyoso...@gmail.com 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.

Hi,

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

Go tohttp://www.microsoft.com/technet/sysinternals/default.mspx
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 - seehttp://wiki.python.org/moin/Win32All) -
if not, its available here:

http://www.python.org/download/releases/2.4.4/
(scroll down the page for the link)

Vasudev Ramwww.dancingbison.com
jugad.livejournal.com
sourceforge.net/projects/xtopdf
Thanks for the ideas...I am already monitoring the registry to see
what happens when I switch between two email clients. In this case, I
am switching between Outlook 2003 and Thunderbird 2. The pertinent
registry files are as follows:

# changes which email client to use
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail]

# obviously changes the .eml file association
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.eml]

# haven't the fogiest idea what this does, if anything
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{29F458B E-8866-11D5-
A3DD-00B0D0F3BAA7}]

# change mailto functionality
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\Default Icon]
@="C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe,0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\o pen\command]
@="\"C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe\" -osint -
compose \"%1\""

I assume you're referring to "Process Monitor", which is a really cool
tool. Maybe it'll help, but I usually can't get it to filter out
enough of the noise to make the output useful. I'll give it a go
nonethless.

I am running all my tests in a VM, so I really don't care if the
registry gets hosed at this point.

Thanks again,

Mike

Jul 20 '07 #3
On Jul 21, 12:28 am, kyoso...@gmail.com wrote:
On Jul 20, 1:48 pm, vasudevram <vasudev...@gmail.comwrote:


On Jul 20, 10:57 pm, kyoso...@gmail.com 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.
Hi,
1: I don't know much about Windows APIs, but am currently reading the
"Windows Internals" book. Got this idea from it:
Go tohttp://www.microsoft.com/technet/sysinternals/default.mspx
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 - seehttp://wiki.python.org/moin/Win32All) -
if not, its available here:
http://www.python.org/download/releases/2.4.4/
(scroll down the page for the link)
Vasudev Ramwww.dancingbison.com
jugad.livejournal.com
sourceforge.net/projects/xtopdf

Thanks for the ideas...I am already monitoring the registry to see
what happens when I switch between two email clients. In this case, I
am switching between Outlook 2003 and Thunderbird 2. The pertinent
registry files are as follows:

# changes which email client to use
[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail]

# obviously changes the .eml file association
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.eml]

# haven't the fogiest idea what this does, if anything
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{29F458B E-8866-11D5-
A3DD-00B0D0F3BAA7}]

# change mailto functionality
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\Default Icon]
@="C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe,0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\o pen\command]
@="\"C:\\Program Files\\Mozilla Thunderbird\\thunderbird.exe\" -osint -
compose \"%1\""

I assume you're referring to "Process Monitor", which is a really cool
tool. Maybe it'll help, but I usually can't get it to filter out
enough of the noise to make the output useful. I'll give it a go
nonethless.

I am running all my tests in a VM, so I really don't care if the
registry gets hosed at this point.

Thanks again,

Mike- Hide quoted text -

- Show quoted text -
You're welcome :)

If Process Monitor has an option to save its output as text files /
CSV files (some of the other SysInternals tools do), you might want to
try using (a Windows version) of grep or awk to filter out the
noise ..

Vasudev
Jul 20 '07 #4
>
If Process Monitor has an option to save its output as text files /
CSV files (some of the other SysInternals tools do), you might want to
try using (a Windows version) of grep or awk to filter out the
noise ..

Vasudev
Well, I ran Process Monitor with some filters enabled to only watch
Thunderbird and MS Word. Unfortunately, that didn't give me any of the
registry edits, so I disabled my filters and ran it without. Now I
have a log file with 28,000 entries. It's amazing to see all the stuff
that happens in just a few moments, but how am I supposed to parse
this mess?

Explorer.exe and outlook express do thousands of the registry calls
and the paths they manipulate vary wildly. Oh well, I'll be off the
clock in about 15 minutes so it can wait until Monday.

Thanks for your help. I'll post if I figure out anything...hopefully
you'll do the same.

Mike

Jul 20 '07 #5
Well, I ran Process Monitor with some filters enabled to only watch
Thunderbird and MS Word. Unfortunately, that didn't give me any of the
registry edits, so I disabled my filters and ran it without. Now I
have a log file with 28,000 entries. It's amazing to see all the stuff
that happens in just a few moments, but how am I supposed to parse
this mess?
I expect you will find it easier figuring out how to install your app
in the SendTo menu rather than making your app callable via MAPI. This
probably involves ShellExtensions but I believe there are utilities
that can be used to add any arbitrary application to the SendTo menu.
That may be enough for your application.

You might want to have a look at SpamBayes for an example of an
Outlook extension written in Python to get an idea of how you can
interface with Outlook.

Jul 22 '07 #6
On Jul 22, 3:00 pm, memra...@yahoo.com wrote:
Well, I ran Process Monitor with some filters enabled to only watch
Thunderbird and MS Word. Unfortunately, that didn't give me any of the
registry edits, so I disabled my filters and ran it without. Now I
have a log file with 28,000 entries. It's amazing to see all the stuff
that happens in just a few moments, but how am I supposed to parse
this mess?

I expect you will find it easier figuring out how to install your app
in the SendTo menu rather than making your app callable via MAPI. This
probably involves ShellExtensions but I believe there are utilities
that can be used to add any arbitrary application to the SendTo menu.
That may be enough for your application.

You might want to have a look at SpamBayes for an example of an
Outlook extension written in Python to get an idea of how you can
interface with Outlook.
We may add it to the Sendto menu, but we have users that want to be
able to use the email functionality from within Office Apps. I've been
planning on reading the SpamBayes source code anyway...however, we're
trying to move away from Outlook. We're currently using Zimbra now and
that's why I'd like to open my Python program with MAPI so I can send
email through our new Zimbra mail server.

I have interfaced with Outlook before using COM, but it's not pretty.

Mike

Jul 23 '07 #7
On Jul 23, 6:07 pm, kyoso...@gmail.com wrote:
>Well, I ran Process Monitor with some filters enabled to only watch
Thunderbird and MS Word. Unfortunately, that didn't give me any of the
registry edits, so I disabled my filters and ran it without. Now I
have a log file with 28,000 entries. It's amazing to see all the stuff
that happens in just a few moments, but how am I supposed to parse
this mess?

Explorer.exe and outlook express do thousands of the registry calls
and the paths they manipulate vary wildly. Oh well, I'll be off the
clock in about 15 minutes so it can wait until Monday.

Thanks for your help. I'll post if I figure out anything...hopefully
you'll do the same.

---

Sorry for not replying earlier ... I searched this list for the topic
(Python MAPI) a few times but couldn't find it - not sure why - maybe
Google Groups's indexing gets messed up sometimes ...

Yes, so many entries would be a problem to parse manually ...

That's why I suggested using a grep for Windows - or, preferably, an
egrep - which is a more powerful version of grep; e.g. basic grep only
allows you to use one regexp at a time - while egrep allows you to use
extended regular expressions, such as "pattern1|pattern2", also
"patt(e|u)rn(1|2)" which looks in parallel for pattern1, patturn1,
pattern2 and patturn2 - I used a made-up example where the spelling of
pattern could be wrong, but it works for any other cases of
alternative patterns and subpatterns as well. Not sure if there is any
egrep for Windows - try Googling. If not, and the problem is important
enough, you might want to install Cygwin (its a big download, so first
check if it _does_ have egrep in it).

Vasudev

Aug 10 '07 #8
On Aug 10, 5:05 am, vasudevram <vasudev...@gmail.comwrote:
On Jul 23, 6:07 pm, kyoso...@gmail.com wrote:
Well, I ran Process Monitor with some filters enabled to only watch

Thunderbird and MS Word. Unfortunately, that didn't give me any of the
registry edits, so I disabled my filters and ran it without. Now I
have a log file with 28,000 entries. It's amazing to see all the stuff
that happens in just a few moments, but how am I supposed to parse
this mess?

Explorer.exe and outlook express do thousands of the registry calls
and the paths they manipulate vary wildly. Oh well, I'll be off the
clock in about 15 minutes so it can wait until Monday.

Thanks for your help. I'll post if I figure out anything...hopefully
you'll do the same.

---

Sorry for not replying earlier ... I searched this list for the topic
(Python MAPI) a few times but couldn't find it - not sure why - maybe
Google Groups's indexing gets messed up sometimes ...

Yes, so many entries would be a problem to parse manually ...

That's why I suggested using a grep for Windows - or, preferably, an
egrep - which is a more powerful version of grep; e.g. basic grep only
allows you to use one regexp at a time - while egrep allows you to use
extended regular expressions, such as "pattern1|pattern2", also
"patt(e|u)rn(1|2)" which looks in parallel for pattern1, patturn1,
pattern2 and patturn2 - I used a made-up example where the spelling of
pattern could be wrong, but it works for any other cases of
alternative patterns and subpatterns as well. Not sure if there is any
egrep for Windows - try Googling. If not, and the problem is important
enough, you might want to install Cygwin (its a big download, so first
check if it _does_ have egrep in it).

Vasudev
There are some programs that do grep for Windows. I'll mess with them.

Mike

Aug 10 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lindstrom Greg - glinds | last post by:
I'm using python 2.3 and Windows 2000 "Professional" to access a Microsoft Exchange Server to monitor messages and perform various tasks around the office. My little program is attracted quite a...
40
by: ian | last post by:
Hi, I'm a newbie (oh no I can here you say.... another one...) How can I get Python to send emails using the default windows email client (eg outlook express)? I thought I could just do the...
3
by: Lenard Lindstrom | last post by:
Posted in a previous thread was some Python code for accessing Window's Simple MAPI api using the ctypes module. http://groups-beta.google.com/group/comp.lang.python/msg/56fa74cdba9b7be9 This...
3
by: Siegfried Heintze | last post by:
Does the Outlook API supersede MAPI? If I implement a SPAM filter using MAPI to automatically delete messages from the message store, will other clients like Eudora benefit? If I implement a...
4
by: Kurt | last post by:
Hi I am using CDO 1.21 from C# in order to iterate through the entries in a users outlook address book (as OOM was too slow). Basically I take the Name field from each "message" and insert it into...
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
3
by: GayathriP | last post by:
This article discusses about how can we access the inbox through MAPI using C# .NET. It also discusses about how to store the attachment in the local directory, how to create a folder in the inbox ...
4
by: venutaurus539 | last post by:
Hello, I was getting an error in Cocreate instance while trying to access "Outlook" using python script. The python script looks like: from win32com.client import Dispatch session =...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.