[python-win32] Using CDO via COM

Christian Wyglendowski Christian.Wyglendowski at greenville.edu
Mon May 3 17:26:26 EDT 2004


Bob,

I think you can ignore the ADODB.Fields bit.  You have a fields collect
in your Configuration object:

c = win32com.client.Dispatch('CDO.Configuration')
c.Fields.Item(cdoSendUsingMethod) = 2                     #see link
below
c.Fields.Item('cdoSMTPServer').Value = 'smarthost'
c.Fields.Item('cdoSMTPConnectionTimeout').Value = 10
c.Fields.Update()

m = win32com.client.Dispatch('CDO.Message')
m.Configuration = c

See this link about cdoSendUsingMethod/cdoSendUsingPort:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/
html/_cdosys_cdosendusing_enum.asp

I did a test with this config and it sent using the SMTP server running
on my workstation.

Hope this helps.

Christian
http://www.dowski.com


-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org] On Behalf Of Bob Gailer
Sent: Monday, May 03, 2004 3:10 PM
To: python-win32 at python.org
Subject: [python-win32] Using CDO via COM


At
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2
k3/_clb_sending_smtp_mail_by_port_25_using_cdosys_vb.asp
there is sample VBA code for using CDOSYS to send mail. Here is the
start of the code:
**** CODE****

'Sending SMTP mail via port 25 using CDOSYS
'This VB sample uses CDOSYS to send SMTP mail using the cdoSendUsingPort
option and specifying a SMTP host.
Private Sub SendMessage(strTo As String, strFrom As String)
'Send using the Port on a SMTP server
Dim iMsg As New CDO.Message
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields
Dim strHTML
Set Flds = iConf.Fields
With Flds
    .Item(cdoSendUsingMethod) = cdoSendUsingPort
    .Item(cdoSMTPServer) = "smarthost"
    'Use SSL to connect to the SMTP server:
    '.Item(cdoSMTPUseSSL) = True
    .Item(cdoSMTPConnectionTimeout) = 10
    .Update
End With

[snip]
I can use win32com.client'Dispatch to get 
CDO.Message and
CDO.Configuration

I don't understand what to do with 
Dim Flds As ADODB.Fields,
and how to get the (I assume constants) cdoSendUsingMethod

etc.
Any guidance will be appreciated.
Bob Gailer
bgailer at alum.rpi.edu
303 442 2625 home
720 938 2625 cell 



More information about the Python-win32 mailing list