View Single Post
  #2 (permalink)  
Old July 7th, 2006, 11:23 PM
cstooch cstooch is offline
Authorized User
 
Join Date: Apr 2006
Location: Edmonton, , Canada.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This command goes at the top of your page:
Code:

Here is the function you use for sending the mail:
Code:
<%'VBScript function to send email using CDOSYS
' Usage: sendEmail "to@somewhere.com", "from@somewhere.com", "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



Reply With Quote