CyberSite.net Knowledge Base
How to Test CDOSYS SMTP Functionality


You can use the following code saved into a file with a .asp extension to test CDOSYS functionality; CDOSYS is a built-in component in ASP, so utilizing it from your ASP code takes no additional effort on your part.

Example using CDOSYS
You will need to change the following variables:

.Item(cdoSMTPServer)
.Item(cdoSendUserName)
.Item(cdoSendPassword)
.To
.From


<%
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername"

Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mail.(domain.com)"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "webmaster@example.com"
.Item(cdoSendPassword) = "yourPassword"

.Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
.To = "Nobody <nobody@example.com>"
.From = "Web Master <webmaster@example.com>"
.Subject = "Test message using CDOSYS SMTP"

.TextBody = "This is a test email message using CDOSYS SMTP Sent @ " & Now()
.Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
%>

BACK TO KNOWLEDGE BASE TABLE OF CONTENTS

HOME | MARKETING | CREATIVE | DEVELOPMENT | MANAGEMENT | PORTFOLIO | PRODUCTS | HOSTING | CLIENT SERVICES | ABOUT CSN | SUPPORT | KNOWLEDGE | LEGAL & PRIVACY | SITE MAP

Copyright 2011 CyberSite.net, a subsidiary of Group One Communications, Inc., All rights reserved worldwide.
Please review our Terms, Conditions, Policies, Procedures, Terms of Use and Service.