A good idea is to place the following subroutine in an include file that holds all your website's subroutines and functions. (Learn more about Include files)
<%
Sub SendEmail(sFrom, sTo, sSubject, sBody)
'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 = sFrom
.To = sTo
.Subject = sSubject
.HTMLBody = sBody
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
End Sub
'Call our subroutine SendEmail
Call SendEmail("from@yoursite.com","recipient@theirsite.com","Hi","Just a test")
%>
Get the best asp web hosting provider now and save 30%
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.