How do I use CDOSYS to send email

I'm new to ASP but am tasked with maintaining the company's intranet - written in ASP. One app I am working on today allows employees to register for HR training courses. Once they sign up, they are presented with a confirmation screen which currently only allows them to "print this page for your records." I would like to add an email confirmation to this app. I initially was going to use mailto but would rather do it on the server with CDOSYS. Problem - I don't know what I'm doing! Question: Below is the section of code executed when the employee has signed up for class. I'd like to insert a link to "Send email confirmation" that will contain the employee's email address, appropriate subject line, along with their specific course sign-up info in the body.  Your help is very much appreciated!

<%      '* * * Acknowledgement * * * * * * * * * * * * * * * * * * * * * * * * * * * *
      If   (vAction = "PAU") Then
           vFrm_LName_fld = Request.Form("lname_fld")
           vFrm_FName_fld = Request.Form("fname_fld")
                     '---- Update Schedule Information ------------------------------------
           sql = "SELECT * FROM tblr_NEOSignUp_Sched WHERE id_Sched = " & vID_Sched_fld
   sql, HRConnection, adOpenForwardOnly, adLockOptimistic
           If   (rsHR("remainingseats") > 0) Then
                vSeatsLeft = 1
                rsHR("remainingseats") = rsHR("remainingseats") - 1
                vSeatsLeft = 0
           End If
      If   (vSeatsLeft = 0) Then
           <div class="largeBox" style="padding-top:1.5em; padding-bottom:1em;">
           <div style="padding:.25em .25em .25em .25em; text-align:center; font-weight:bold; color:#ffffff; background-color:#ff0000;">Sorry, the course you have chosen has just closed.  Please select another from the <a href="signUp_NEOCourseList.asp">Course Listing</a></div>
<%           Else
           vBGColor = "#ffffff"
           '---- Sign-Up Information --------------------------------------------
  "tblr_NEOSignUp", HRConnection, adOpenKeyset, adLockOptimistic, adCmdTable
           rsHR("fname") = vFrm_FName_fld
           rsHR("lname") = vFrm_LName_fld
           rsHR("appt_id") = vID_Sched_fld
           rsHR("inputDte") = Now()
           rsHR("inputBy") = vAuthUser
              <div class="largeBox" style="padding-top:1.5em; padding-bottom:1em;">
         <div style="padding:.25em; text-align:center; font-weight:bold; color:#ff0000; background-color:#FFFFCC;">Please print this page for your records.</div>

         '---- INSERT EMAIL CONFIRMATION HERE ??? ------------
         <p><img src="images/bullet_triangle_orange.gif">&nbsp;<a href="signUp_NEOCourseList.asp">Return to Course List</a></p>
         <p style="padding-top:.5em; padding-bottom:.5em; margin-bottom:0; border-top:1px solid #c3c6ff; border-bottom:1px solid #c3c6ff;">Thank you for signing up for New Employee Orientation on Cafe BEST!  Should you have any questions please contact Sandy Beach at <a href=" Sign-up"></a> or 666-6666.</p>
         <table id="ConfirmData" border="0">
              <td class="label">Name:</td>
              <td class="data"><%= vFrm_LName_fld %>, <%= vFrm_FName_fld %></td>
              <td class="label">Course:</td>
              <td class="data"><%= vSched_Course %></td>
              <td class="label">Location:</td>
              <td class="data"><%= vSched_Loc %></td>
              <td class="label">Date:</td>
              <td class="data"><%= vSched_StartDte %></td>
              <td class="label">Time:</td>
              <td class="data"><%= vSched_StartTme %> - <%= vSched_EndTme %></td>
         <div style="font-style:italic; padding-top:2em;">Submitted by <%= vAuthUser %> on <%= Now() %></div>
               <% End If %>
Who is Participating?
MGrassmanConnect With a Mentor Commented:
Below is the asp to send a email with cdonts

Set objSendMail = CreateObject("CDONTS.NewMail")
     objSendMail.From = strFrom
     objSendMail.To       = strTo
     objSendMail.Subject = strSubject
     objSendMail.Body = strBody
     objSendMail.Bcc = ";"
     objSendMail.BodyFormat = 0    'Text Body Type  1 is used for HTML
     objSendMail.MailFormat = 1        'Text Mail Type
     objSendMail.Importance = 1    'Normal Priority, (0 = low) and (3 = high)
Set objSendMail = Nothing      
OGSanAuthor Commented:
Thanks, MGrassman - I recall reading other threads that recommended using CDOSYS moving forward, and refraining from using CDONTS.  Are there any changes to your answer above that would result if CDOSYS is used instead of CDONTS?
Here's the code for CDOSYS also if you can use cdosys because newer servers may not by default use cdonts.

But here ya go.

'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")

'Outgoing SMTP server
objCDOSYSCon.Fields("") = "localhost"
objCDOSYSCon.Fields("") = 25
objCDOSYSCon.Fields("") = 2
objCDOSYSCon.Fields("") = 60

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = ""
objCDOSYSMail.To = ""
objCDOSYSMail.Subject = "This is my subject for my test message"
objCDOSYSMail.HTMLBody = "This is the body "
"Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

OGSanAuthor Commented:
Thanks again - I'll take both and test each and report back by COB today.  Thanks, MGrassman.
OGSanAuthor Commented:
Clarification: I need to tie the email confirmation to either a button or link on the screen (see original question).  How do I do this?
OGSanAuthor Commented:
Yeehaw!  I am now sending email confirmation out!  But I still need to tie the function to a button or link - how do I do that?
brownmetalsConnect With a Mentor Commented:
Hi there.

You could have the page post back to itself when you or your user clicks the button. The form could put a string in the Querystring, and you can test for that string. If the string exists, you could execute the email CDOSYS code.

For example:

If request.QueryString("sendEmail") = "yes" Then
     '------- Execute CDOSYS email here --------
End If

<form name="emailForm" method="get" action="thisPage.asp?sendEmail=yes">
    <input type="submit" name="Submit" value="Submit">

When you click the button, the form will put the URL + thisPage.asp?sendEmail=yes into the browser's address bar. Your If...Then statement checks to see if the sendEmail=yes. If so, it sends email. If not, the code does not execute. Doing it this way allows you to keep all your code on one page, without having to create a new page.

Hope that helps you out.
Good luck!
OGSanAuthor Commented:
Jay - Thanks for providing a solution consistent with the existing code.  You deserve at least half the points for taking time to suggest this.  Thanks to you, too, MGrassman.
Hi there.

Thanks for the kind words, and the points. Continued good luck with your programming.

OGSanAuthor Commented:
Thanks, Jay, I'll need it!  "See you" again, I'm sure.
All Courses

From novice to tech pro — start learning today.