Python To Send Emails Via Outlook Express

Ganesan R rganesan at myrealbox.com
Tue Dec 21 07:24:22 CET 2004


>>>>> "ian" == ian  <ian at kirbyfooty.com> writes:

> Hi Ganesan,
> I'm on the verge of giving up <sigh>
> I don't suppose you could write a small script to send the email for me
> via the default windows email client. 

I can see no easy way to do this. Though you can access the default mail
client using a registry key (I don't have enough win32 programming
experience to do this), there is no guarantee that the email client is a COM
server. Even Outlook Express is not a COM server. What if the user has
configured Eudora or something like that?

The best we can do is use Outlook Express settings and send the mail.

> I will then try running your script and my end to see if it works ok.  I
> may have missed something and would really appreciate your help.  

The final script that you pasted:

=====
import win32com.client

s = win32com.client.Dispatch('CDO.Message')
s.From = "ian at cgbs.com.au"
s.To = "ian at kirbyfooty.com"
s.Subject = "The subject"
cdoSourceOutlookExpress        = 2
s.Configuration.Load(cdoSourceOutlookExpress)
s.Send()
=====

works fine for me. According to CDO.Message documentation, if IIS is
installed that configuration will be used by default, followed by OE
configuration. I don't have IIS installed, so the script picked up the OE
configuration automatically for me. Here's a variation of the above
script. 

======
import win32com.client

s = win32com.client.Dispatch('CDO.Message')
c = win32com.client.Dispatch('CDO.Configuration')
cdoSourceOutlookExpress = 2
c.Load(cdoSourceOutlookExpress)
s.Configuration = c
s.From = "ian at cgbs.com.au"
s.To = "ian at kirbyfooty.com"
s.Subject = "The subject"

s.Send()
======

If that doesn't help, I give up :-(. 

Ganesan



More information about the Python-list mailing list