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

Joshua Kaderlan jek at zer0.org
Wed Nov 16 02:35:46 CET 2005


On 2005-11-16 12:23 +1100, Mark Hammond <mhammond at skippinet.com.au> wrote:
> 
> > 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.

You can download the Outlook 2003 Visual Basic Application Reference (which, 
despite the name, is the Simple MAPI documentation; it uses VB for sample code 
though) from MSDN:
<http://www.microsoft.com/downloads/details.aspx?FamilyId=A1CEAD80-23E2-456F-8618-4DA50CC2C38C&displaylang=en>

Doing what you suggest above (or something very similar to it) will probably
work, although it'll trigger the Outlook security dialog.  If you want to get
around that, either use Extended MAPI or the Outlook Redemption DLL:
<http://www.dimastr.com/redemption>  
There are also a couple of apps which will allow you to use the regular Simple
MAPI calls and programmatically suppress the dialog.


-Josh


More information about the Python-win32 mailing list