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
            rsHR.open sql, HRConnection, adOpenForwardOnly, adLockOptimistic
           If   (rsHR("remainingseats") > 0) Then
                vSeatsLeft = 1
                rsHR("remainingseats") = rsHR("remainingseats") - 1
                rsHR.update
           Else
                vSeatsLeft = 0
           End If
                rsHR.close
      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>
           </div>
<%           Else
           vBGColor = "#ffffff"
           '---- Sign-Up Information --------------------------------------------
           rsHR.open "tblr_NEOSignUp", HRConnection, adOpenKeyset, adLockOptimistic, adCmdTable
           rsHR.AddNew
           rsHR("fname") = vFrm_FName_fld
           rsHR("lname") = vFrm_LName_fld
           rsHR("appt_id") = vID_Sched_fld
           rsHR("inputDte") = Now()
           rsHR("inputBy") = vAuthUser
           rsHR.update
           rsHR.close
%>
              <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="mailto:sandy.beach@company.com?Subject=NEO Sign-up">sandy.beach@company.com</a> or 666-6666.</p>
         <table id="ConfirmData" border="0">
           <tr>
              <td class="label">Name:</td>
              <td class="data"><%= vFrm_LName_fld %>, <%= vFrm_FName_fld %></td>
         </tr>
         <tr>
              <td class="label">Course:</td>
              <td class="data"><%= vSched_Course %></td>
         </tr>
         <tr>
              <td class="label">Location:</td>
              <td class="data"><%= vSched_Loc %></td>
         </tr>
         <tr>
              <td class="label">Date:</td>
              <td class="data"><%= vSched_StartDte %></td>
         </tr>
         <tr>
              <td class="label">Time:</td>
              <td class="data"><%= vSched_StartTme %> - <%= vSched_EndTme %></td>
         </tr>
         </table>
         <div style="font-style:italic; padding-top:2em;">Submitted by <%= vAuthUser %> on <%= Now() %></div>
               </div>
               <% End If %>
      
LVL 1
OGSanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MGrassmanCommented:
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 = "email@companie.com;email2@companie.com"
     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)
      
     objSendMail.Send
Set objSendMail = Nothing      
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
0
MGrassmanCommented:
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("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
objCDOSYSMail.From = "you@yourdomain.com"
objCDOSYSMail.To = "recipient@theirdomain.com"
objCDOSYSMail.Subject = "This is my subject for my test message"
objCDOSYSMail.HTMLBody = "This is the body "
objCDOSYSMail.Send
"Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
%>
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

OGSanAuthor Commented:
Thanks again - I'll take both and test each and report back by COB today.  Thanks, MGrassman.
0
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?
0
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?
0
brownmetalsCommented:
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">
  <p>&nbsp;</p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>

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!
Jay
0
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.
0
brownmetalsCommented:
Hi there.

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

Jay
0
OGSanAuthor Commented:
Thanks, Jay, I'll need it!  "See you" again, I'm sure.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.