This command goes at the top of your page:
Here is the function you use for sending the mail:
Code:
<%'VBScript function to send email using CDOSYS
' Usage: sendEmail "[email protected]", "[email protected]", "Subject", "Body"
Function sendEmail(address_to, address_from, subject, body)
'the mail object
Dim ObjMail
Set ObjMail = CreateObject("CDO.Message")
'mail configuration
Dim objConfig
Set objConfig = CreateObject("CDO.Configuration")
'replace any line breaks in the mail body with <br> tag for HTML email
emailBody = Replace(body, chr(10), "<br>")
'set up the mail server, port etc.
With objConfig
.Fields(cdoSendUsingMethod) = cdoSendUsingPort
'Try Local Machine
.Fields(cdoSMTPServer) = "someservernamehere" 'change the server name, of course
.Fields(cdoSMTPServerPort) = 25
.Fields(cdoSMTPAuthenticate) = cdoBasic
.Fields.Update
End With
'the message
With objMail
.Configuration = objConfig
.From = address_from
.To = address_to
.Subject = subject
.HTMLBody = emailBody 'for sending HTML email
'.TextBody = emailBody 'for sending Text only email
.Send
End With
Set objMail = Nothing
Set objConfig = Nothing
End Function
%>
Then just call this function like so:
sendEmail EmailToSendTo, EmailToSendFrom, Subject, BodyOfTheEmail