[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I use CDOSYS to send email

Posted on 2004-10-26
10
Medium Priority
?
595 Views
Last Modified: 2012-06-27
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 %>
      
0
Comment
Question by:OGSan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
10 Comments
 
LVL 2

Accepted Solution

by:
MGrassman earned 750 total points
ID: 12415431
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
 
LVL 1

Author Comment

by:OGSan
ID: 12415814
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
 
LVL 2

Expert Comment

by:MGrassman
ID: 12415940
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:OGSan
ID: 12416018
Thanks again - I'll take both and test each and report back by COB today.  Thanks, MGrassman.
0
 
LVL 1

Author Comment

by:OGSan
ID: 12417219
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
 
LVL 1

Author Comment

by:OGSan
ID: 12417758
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
 
LVL 4

Assisted Solution

by:brownmetals
brownmetals earned 750 total points
ID: 12418550
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
 
LVL 1

Author Comment

by:OGSan
ID: 12430861
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
 
LVL 4

Expert Comment

by:brownmetals
ID: 12435407
Hi there.

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

Jay
0
 
LVL 1

Author Comment

by:OGSan
ID: 12436580
Thanks, Jay, I'll need it!  "See you" again, I'm sure.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question