How do I 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.

We strongly recommend using an SMTP relay that requires authentication.  Sending mail through unauthenticated SMTP servers (including the localhost relay on Cloud Sites) can result in delays or undelivered email due to stringent anti-spam filters.

Example using CDOSYS

You will need to change the following variables:

  • .Item(cdoSMTPServer)
  • .Item(cdoSendUserName)
  • .Item(cdoSendPassword)
  • .To
  • .From
Const cdoSendUsingMethod       = ""
Const cdoSendUsingPort         = 2
Const cdoSMTPServer            = ""
Const cdoSMTPServerPort        = ""
Const cdoSMTPConnectionTimeout = ""
Const cdoSMTPAuthenticate      = ""
Const cdoBasic                 = 1
Const cdoSendUserName          = ""

Const cdoSendPassword          = ""

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.("
        .Item(cdoSMTPServerPort)        = 25
        .Item(cdoSMTPConnectionTimeout) = 10
        .Item(cdoSMTPAuthenticate)      = cdoBasic
        .Item(cdoSendUserName)          = ""
        .Item(cdoSendPassword)          = "yourPassword"

End With

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

Set objMessage.Configuration = objConfig

With objMessage
        .To       = "Nobody <>"
        .From     = "Web Master <>"
        .Subject  = "Test message using CDOSYS SMTP"

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

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing

See Also

Was this content helpful?

© 2015 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER