1. Home
  2. Support
  3. Scripting
  4. Sending email within ASP using CDOSYS

Sending email within ASP using CDOSYS

CDOSYS is an inbuilt component within ASP itself, so there are no additional programs or plug-ins needed.

Sample code (edit the sections that LOOK_LIKE_THIS):

If Request.Form(“submit”) <> “” Then
Set myMail=CreateObject(“CDO.Message”)
myMail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
myMail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “dwebform.pipeten.co.uk”
myMail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
myMail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”) = 0
myMail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/sendusername”) = “”
myMail.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/sendpassword”) = “”
myMail.Subject= “CONTACT_US_FROM_WEBSITE” ‘This is the subject of the e-mail
myMail.To=”YOUR_EMAIL@MAIL.COM” ‘This is the e-mail address the e-mail will be delivered to
myMail.TextBody=”Name: ” & Request.Form(“name”) & vbnewline & “E-Mail Address: ” & Request.Form(“emaddress”) & vbnewline & “Message: ” & Request.Form(“message”)
set myMail=nothing
End If
<title>Contact Us</title>
<form method=”POST” action=””>
Name: <input type=”text” name=”name” size=”20″><br>
E-mail Address: <input type=”text” name=”emaddress” size=”20″><br>
Message: <input type=”text” name=”message” size=”80″>
<input type=”submit” value=”Submit” name=”submit”>
<input type=”reset” value=”Reset” name=”reset”>

Save the above code in your favourite editor as an .asp file then upload to your website. Please be aware that when sending emails from your website, if you have the option to specify the outgoing server you should use web form, our specialised mail server.

You will also need to create your own thank you page that the user is redirected to once they have submitted the form. You can call this whatever you like, just remember to update the URL in the code from THANK_YOU_PAGE.html to your page name.

Classification: Public
Last modified: 2019/08/14 at 15:14 by Jamie