473,231 Members | 1,602 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,231 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 4088
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.