[python-win32] mapisend.py - How does it work?

Mark Hammond mhammond at skippinet.com.au
Wed Nov 16 02:23:49 CET 2005


> Specifically I was wondering:
> Does it require that I have outlook installed?

It requires outlook plus the "simple mapi", or "cdo" libraries.  These are
an optional component of the office 2000 install that is de-selected by
default (ie, you need to explicitly install it).  Worse, for later Outlook
versions you always get "nag" dialogs in MS' attempt at stopping malware
from sending mail or accessing your contacts.

> Does it require that there is an exchange server somewhere?
> What is the role of the email server in all of this?  Is there
> an SMTP server somewhere in the process?

The MAPI libraries themselves take care of this detail.  Really, it is just
Outlook that sends the mail however it is configured to do so (ie, either
directly to an smtp server, or to an exchange server).  So it does not
*need* an exchange server.

> B. I was asked to send emails through my company's exchange server.  (will
this count?)
> Any pointers on how to do this otherwise?

If your exchange server is acting as an SMTP server you could just use
smptlib.  Otherwise you could use "extended MAPI", which is fully supported
by Python, but somewhat tricky to use.  Also, something like:

app = Dispatch("Outlook.Application")
new_msg = app.CreateItem(0)
new_msg.Body = "hello"
...
new_msg.Send()

may work - I've actually no idea if it does, but something similar should :)
The trick here would be to find docs for the Outlook object model (eg, VB
code that uses it).  This will obviously depend on Outlook being installed.

Mark



More information about the Python-win32 mailing list