Send an Email with CDOSYS

CDONTS (Collaboration Data Objects for NT Server) is deprecated on Windows XP and Windows 2003 and only included on Windows 2000 for backward compatability. CDOSYS (Collaboration Data Objects For Windows 2000) is it's successor and it is recommended that you use CDOSYS instead of CDONTS to send emails with ASP.

The CDO component comes installed by default on Windows 2000, 2003 and XP Professional.

<%
Option Explicit
'Declare variables
Dim sch, cdoConfig, cdoMessage
sch = "http://schemas.microsoft.com/cdo/configuration/"
 
    Set cdoConfig = CreateObject("CDO.Configuration")
 
    With cdoConfig.Fields
        'Set CDO Port
        .Item(sch & "sendusing") = 2
        'Set mailserver name either IP address, mail.yoursite.com or localhost
        .Item(sch & "smtpserver") = "127.0.0.1"
        'Set SMTP port which is 25 by default
        .Item(sch & "smtpserverport") = 25
        'Set number of seconds before timeout
        .Item(sch & "smtpconnectiontimeout") = 60
        .update
    End With
 
    Set cdoMessage = CreateObject("CDO.Message")
 
    With cdoMessage
        Set .Configuration = cdoConfig
        .From = "youremail@yoursite.com"
        .To = "recipient@theirsite.com"
        .Subject = "Test Email"
        'Send the email in HTML format
        .HTMLBody = "This is a test email."
        .Send
    End With
 
    Set cdoMessage = Nothing
    Set cdoConfig = Nothing
%>

You could encapsulate the code above in an CDOSYS email subroutine

Get the best asp web hosting provider now and save 30%

Advertisements



MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.