CDO Messaging

M

Marlon

please anyone, kindly enlighten me...

im using CDO do send email with attachment to a specific
SMTP server in VBScript (*.vbs file). i just used a
sample code i found on the net, here it is:

set objMessage = CreateObject("CDO.Message")
objMessage.Subject = subj
objMessage.Sender = "(e-mail address removed)"
objMessage.From = "Fax Server"
objMessage.ReplyTo = "(e-mail address removed)"
objMessage.To = emailadd
objMessage.AddAttachment filename

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing"
) = 2

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver
") = "192.168.0.12"

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver
port") = 25

objMessage.Configuration.Fields.Update

objMessage.Send

i dont have much background about CDO, i just want to know
why the script include lines such
as "("http://schemas.microsoft.com/cdo/configuration/smtpse
rverport")"? does the pc where im running this script
needs a internet access? and any other site i could use
for reference about this object?

thanks!!!
marlon
 
N

neo [mvp outlook]

No. The PC does not need internet access, it just needs LAN/WAN
connectivity. The lines are telling the CDO library that you wish to send
the message via a port request and that it should try and connect on port 25
to 192.168.0.12.
 
E

Ed Astle

The http://schema.microsoft.com/blah things are just unique keys to access
configuration items. They could have used GUIDS but then they wouldn't mean
much to the programmer.

Alternatively (in vb6) use the type library "Microsoft CDO for Windows 2000
Library". Then you can do:

Dim fields As ADODB.fields

Set m_cdomsg = New CDO.Message
Set m_cdocfg = New CDO.Configuration
Set fields = m_cdocfg.fields
fields(cdoSMTPServer) = sServer
fields(cdoSMTPServerPort) = CLng(sPort)
fields(cdoSMTPAuthenticate) = cdoAnonymous
fields(cdoSendUsingMethod) = cdoSendUsingPort
fields.Update
Set fields = Nothing
Set m_cdomsg.Configuration = m_cdocfg

m_cdomsg.From = Trim(sFrom)
m_cdomsg.Subject = Trim(sSubject)
etc.

In ASP I've used this too:

<% ' GUID for Microsoft CDO for Windows 2000 Library... %>
<!-- METADATA TYPE="TypeLib" UUID="{CD000000-8B95-11D1-82DB-00C04FB1625D}"
VERSION="1.0"-->

Dim cdomsg ' As CDO.Message
Dim cdocfg ' As CDO.Configuration
Dim fields ' As ADODB.fields

Set cdomsg = Server.CreateObject( "CDO.Message" )
Set cdocfg = Server.CreateObject( "CDO.Configuration" )
Set fields = cdocfg.Fields

fields( cdoSMTPServer ) = Application( "sEmailServer" )
fields( cdoSMTPServerPort ) = Application( "nEmailServerPort" )
fields( cdoSMTPAuthenticate ) = cdoAnonymous
fields( cdoSendUsingMethod ) = cdoSendUsingPort
fields.Update
etc.

Both the above snippets used on win2k server.
Regards,
Ed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top