Link to home
Start Free TrialLog in
Avatar of elieazzi
elieazziFlag for United States of America

asked on

SEND by Email - SEND FUNCTION.

Hello Everyone,

At the end of this code i've a function SEND email.  FYI, I have an online form where it request the name and telephone numbers of clients who went to receive materials online.  All the request currently go into the Database.  Everything work perfect.  

I'm trying to add a SEND Mail function at the button of the code, to notify me that a user has fill the form online.  Can you please check my SENDMAIL function at the end of this page. VERY EASY to read, please see the ************** ASTEROC.

Thank you, God bless you.

........
</body>
</html>


<%
'------------------------------------------------------------------------------
' BEGIN Server-side functions
' -----------------------------------------------------------------------------
sub Main()
    CreateGlobalObjects
   
    Dim strAction, strConfirm
    strAction = rq("userAction")
    strConfirm = rq("confirm")
   
    select case strAction
        case "SAVESURVEY":
            call SaveSurveyResponse()
           
            if bDisplayForm = false then
                'this will avoid resubmitting the form if browser reload button is pressed
                Response.Redirect "default.asp?confirm=1"
            end if    
       
        case else
            if strConfirm = "1" then
                bDisplayForm = false
                FormatMsgToUser "Your survey results were successfully saved.  Thank-you."
            else
                bDisplayForm = true
            end if
    end select

    CleanUpGlobalObjects

end sub


sub CreateGlobalObjects
    on error resume next
    set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open ConnectString
   
end sub


sub CleanUpGlobalObjects
    on error resume next
    if oConn.state = 1 then
        oConn.close
    end if
    set oConn = nothing
end sub


sub SaveSurveyResponse()
    on error resume next
    dim strSQL, iRecordsAffected, adoRS, iResponseID, strSQL2, strBaseSQL
    iRecordsAffected = 0
   
   

    strSQL = "INSERT INTO SUR_Responses (DateEntered) VALUES ('" & now() & "')"

    oConn.Execute strSQL, iRecordsAffected
   
    set adoRS = Server.CreateObject("ADODB.RecordSet")
    Set adoRS = oConn.Execute("SELECT @@IDENTITY")
   
    if not (adoRS.EOF or adoRS.BOF) then
        iResponseID = adoRS(0)
    end if
   
    if err.number = 0 then
        strBaseSQL = "INSERT INTO SUR_ResponsesAnswers (ResponseID, QuestionNo, QuestionPartNo, AnswerID, Comment) " & _
                      "VALUES (" & iResponseID & ","
   
        strSQL2 = strBaseSQL & "1,0," & FormatSurveyOptionForDB(rq("selQ1")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "2,0," & FormatSurveyOptionForDB(rq("selQ2")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "3,0," & FormatSurveyOptionForDB(rq("radQ3")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "4,0," & FormatSurveyOptionForDB(rq("radQ4")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "5,0," & FormatSurveyOptionForDB(rq("radQ5")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "6,0," & FormatSurveyOptionForDB(rq("radQ6")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "7,0," & FormatSurveyOptionForDB(rq("selQ7")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "8,0," & FormatSurveyOptionForDB(rq("radQ8")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "9,0," & FormatSurveyOptionForDB(rq("radQ9")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "10,0," & FormatSurveyOptionForDB(rq("radQ10")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "11,0," & FormatSurveyOptionForDB(rq("radQ11")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,1," & FormatSurveyOptionForDB(rq("radQ12A")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12A")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,2," & FormatSurveyOptionForDB(rq("radQ12B")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12B")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,3," & FormatSurveyOptionForDB(rq("radQ12C")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12C")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,4," & FormatSurveyOptionForDB(rq("radQ12D")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12D")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,5," & FormatSurveyOptionForDB(rq("radQ12E")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12E")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,6," & FormatSurveyOptionForDB(rq("radQ12F")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12F")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "13,0," & FormatSurveyOptionForDB(rq("radQ13")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "14,0," & FormatSurveyOptionForDB(rq("radQ14")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "15,0," & FormatSurveyOptionForDB(rq("radQ15")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "16,0,0,'" & FormatSurveyCommentForDB(rq("txtQ16")) & "')" & vbCrLf
       
                 
        oConn.Execute strSQL2, iRecordsAffected
       
        if err.number = 0 then
            bDisplayForm = false
        else
            bDisplayForm = true
            FormatMsgToUser "An error occurred while processing your request.  Please try again later."
            AddToDebugString "Error:SaveSurveyResponse(): " & err.number & " - " & err.Description, true
        end if
   
    else
        bDisplayForm = true
        FormatMsgToUser "An error occurred while processing your request.  Please try again later."
        AddToDebugString "Error:SaveSurveyResponse(): " & err.number & " - " & err.Description, true
    end if
   

    if blnDebug then
        AddToDebugString "strSQL=" & strSQL, true
        AddToDebugString "strSQL2=" & strSQL2, false
        AddToDebugString "iResponseID=" & iResponseID, false
        AddToDebugString "iRecordsAffected=" & iRecordsAffected, false
    end if
   
    if adoRS.State = 1 then
        adoRS.Close
    end if
    set adoRS = nothing
   
end sub

function FormatSurveyCommentForDB(str)
    if str <> "" then
        str = replace(str,"'","''")
    end if
    FormatSurveyCommentForDB = str
end function

function FormatSurveyOptionForDB(str)
    'used to manipulate text input for datbase storage
    if str = "" then
        str = "0"
    end if
    FormatSurveyOptionForDB = str
end function

'------------------------------------------------------------------------------
' END Server-side functions
' -----------------------------------------------------------------------------


' *************** HELP ME HERE PLEASE **********************
' *******************************************************
' I ve add the function SENDMAIL() but it's not working is anyone is
' able to help me to fix this function sendmail().  I want the name to be sent
' by email.  
' *******************************************************
' *******************************************************

' IS THIS BELOW at the correct place in this code?

' eMail variables
emailRecipient = "lelloazzi@hotmail.com"
emailSender = "info@ccc.org"
emailSubject = "Request for Materials (via website)"
emailBody = ""

' Check input
strMsg = ""

' HERE IS THE FUNCTION.

function sendMail()
      dim successFlag
      successFlag = true
      ' Prepare body
      emailBody = emailBody & "<font size=""+1""><b>Request for Materials</b></font>" & "<br><br>"
      emailBody = emailBody & "<b>Name: </b>" & Trim(rq("TXTQ12A")) & "<br>"

      ' Prepare object and send mail
      on error resume next
    Set objMail = Server.CreateObject("CDO.Message")
    objMail.From = emailSender & " <" & emailSender & ">"
    objMail.To = emailRecipient & " <" & emailRecipient & ">"
    objMail.Subject = emailSubject
    objMail.HTMLBody = CStr("" & emailBody)
    objMail.Send
   
    ' If error encountered, set flag
    If err.number <> 0 Then
            successFlag = false
      end if

    on error goto 0
     
    ' Clean up
    if isobject(objMail) then set objMail = nothing

    ' Return flag
      sendMail = successFlag
end function

' END OF this function, anyone can able to help me fix the sendmail function.

%>
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

First--

Do you know for certain that you have CDO installed and functioning correctly?

FtB
Here is a script from ap_asjith:

' ** SUBROUTINE TO SEND EMAIL USING CDOSYS **

'**USAGE **
'strMailBody="<Font Color=Red><B>Test HTML String</B></Font>"
'CALL SendMailCDOSYS("a@b.com","c@d.com","test",strMailBody,True,"mail.yahoo.com")

Sub SendMailCDOSYS(strFrom,strTO,strSubject,strMailBody,blnHTML,sMailServer)
On Error Resume Next
     Dim objCDOConf,objCDOSYS
     ' ** CREATE THE E-MAIL SERVER OBJECT **
     Set objCDOSYS = Server.CreateObject("CDO.Message")
     Set objCDOConf = Server.CreateObject ("CDO.Configuration")

     ' ** SET AND UPDATE FIELDS PROPERTIES **
     With objCDOConf
          ' ** OUT GOING SMTP SERVER **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServer
          ' ** SMTP PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport")  = 25
          ' ** CDO PORT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
          ' ** TIMEOUT **
          .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
          .Fields.Update
     End With

     ' ** UPDATE THE CDOSYS CONFIGURATION **
     Set objCDOSYS.Configuration = objCDOConf

     With objCDOSYS    
          ' ** WHO THE E-MAIL IS FROM **
          .From = strFrom

          ' ** WHO THE E-MAIL IS SENT TO **
          .To = strTo
                   
          ' ** THE SUBJECT OF THE E-MAIL **
          .Subject = strSubject
           
          ' ** SET THE E-MAIL BODY FORMAT (HTMLBody=HTML TextBody=Plain) **
          If blnHTML = True Then
          .HTMLBody = strMailBody
          Else
          .TextBody = strMailBody
          End If
           
          ' ** SEND THE E-MAIL **
          .Send
     End with                    
       
     ' ** CLOSE THE SERVER MAIL OBJECT **
     Set objCDOSYS = Nothing
End Sub



FtB
Avatar of gotaluvme
gotaluvme


Move the following into your Sendmail  subroutine

' eMail variables
emailRecipient = "lelloazzi@hotmail.com"
emailSender = "info@ccc.org"
emailSubject = "Request for Materials (via website)"
emailBody = ""


You also need to have OPTION EXPLICIT at the top of your asp page, on the second line.
You should DIM all your variables

DIM EmailRecipient, emailSender,emailSubject   etc.


The emailSender variable, which you have populated with "info@ccc.org"  must be a valid email address on the mail server.  Am I correct in assuming ccc.org, is the website you have email?
Avatar of elieazzi

ASKER

Currently I've did what you've told me for the email variables.  I'm cliquing submit the information are going into the database but i'm not receiving any emails .

Woudl you please advice if my code below is good...

<%@ Language=VBScript %>
<%Option Explicit%>

This is the form pages
......

'------------------------------------------------------------------------------
' END Server-side functions
' -----------------------------------------------------------------------------
function sendMail()

DIM EmailRecipient, emailSender, emailSubject, emailBody, strMsg
'eMail variables
emailRecipient = "lilloazzi@hotmail.com"
emailSender = "lelloazzi@hotmail.com"
emailSubject = "Request for Materials (via website)"
emailBody = ""

' Check input
strMsg = ""
' Send Mail function

      dim successFlag
      successFlag = true
      ' Prepare body
      emailBody = emailBody & "<font size=""+1""><b>Request for Materials</b></font>" & "<br><br>"
      emailBody = emailBody & "<b>Name: </b>" & Trim(rq("TXTQ12A")) & "<br>"

      ' Prepare object and send mail
      on error resume next
    Set objMail = Server.CreateObject("CDO.Message")
    objMail.From = emailSender & " <" & emailSender & ">"
    objMail.To = emailRecipient & " <" & emailRecipient & ">"
    objMail.Subject = emailSubject
    objMail.HTMLBody = CStr("" & emailBody)
    objMail.Send
   
    ' If error encountered, set flag
    If err.number <> 0 Then
            successFlag = false
      end if

    on error goto 0
     
    ' Clean up
    if isobject(objMail) then set objMail = nothing

    ' Return flag
      sendMail = successFlag
end function
%>

If you don't have luck with that, please take a look at my post above.

FtB
You may need to check to see if your smpt server is running.  if you using the same machine to send the mail check the smpt server in the iis config, if it's not there you may need to install it.

If you aren't getting any errors from memory the messages are placed into one of the folders in c:\inetpub\mailroot
FYI, the STMP server was running on my server good.  I found this code and I've tryed it's working. but I need to insert in the body the users response which is the field "txtQ16".      How i'm able to grap the user response and put it in this code below replacind this line 'objMail.body="sstr" ' set the message content'.... Thank you.

I did this is working perfect.

dim objMail, msgto
   set objMail=server.CreateObject("CDONTS.NewMail")
   objMail.To="lelloazzi@hotmail.com"                'set TO address
   objMail.from="lelloazzi@hotmail.com"            'set FROM address
   objMail.value("reply-to") ="lelloazzi@hotmail.com" 'set reply to address
   objMail.subject="testmsgsubject"       'set the subject line
   objMail.body="sstr"                 'set the message content  
   objMail.send                       'send the message
   set objMail=nothing                'destroy the component
   'Response.Write "done"

It's wokring fine.  But I need to make a change for to insert in the objMail.Body a content of my field with is question2 below.


Do you have any comments or suggestions to improve the website? Be as general or specific as you wish.  

-------------------------------------------------------------------
|                                                                                 |
-------------------------------------------------------------------

This is the code for the previous question:
<tr>
      <td valign="top">16.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Do you have any comments or suggestions to improve the website?  Be as general or specific as you wish.  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <TEXTAREA rows=4 cols=60 id=txtQ16 name=txtQ16></TEXTAREA>
      </td>
    </tr>

So you would get the result like this:

objMail.body="Request.Form("txtQ16")

FtB
FYI, Any idea please:

I got this error when I load the page:

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/en/survey/Default.asp, line 849

objMail.body="Request.Form("txtQ16")
----------------------------^


dim objMail, msgto
   set objMail=server.CreateObject("CDONTS.NewMail")
   objMail.To="elie_azzi@caf-fca.org"                'set TO address
   objMail.from="elie_azzi@caf-fca.org"            'set FROM address
   objMail.value("reply-to") ="elie_azzi@caf-fca.org" 'set reply to address
   objMail.subject="testmsgsubject"       'set the subject line
  objMail.body="Request.Form("txtQ16")  
   objMail.send                       'send the message
   set objMail=nothing                'destroy the component
   'Response.Write "done"
 
                        
            else
                bDisplayForm = true
            end if
    end select

    CleanUpGlobalObjects

end sub
FYI, this is all my code:

<%@ Language=VBScript %>
<%Option Explicit%>
<!--#include virtual="/globalincludes/global.routines.inc"-->
<!--#include virtual="/globalincludes/database.inc"-->
<!-- #include virtual="/en/includes/htmlhead.inc" -->

 
<%
'==============================================================================
'              AppName = CAF-FCA Canadian Apprenticeship Forum
'==============================================================================
'
'             VSS Version: $Revision: 5 $
'        Last Modified by: $Author: Ttf $
'            Last Checkin: $Date: 2/10/04 3:43p $
'  Last Modification Time: $Modtime: 2/10/04 3:32p $
'                FileName: $Workfile: default.asp $
'
'             Description: Popup page presents UAT survey.
'
'==============================================================================
' DO NOT EDIT VERSION INFO ABOVE - Automatically updated by SourceSafe at Check-in

'------------------------------------------------------------------------------
' BEGIN Global Server-side Variables
' -----------------------------------------------------------------------------

Dim blnDebug, strDebug

'to enable debugging
blnDebug = false

dim oConn, bDisplayForm, strMsgToUser

'------------------------------------------------------------------------------
' END Global Server-side Variables
' -----------------------------------------------------------------------------

call Main() 'sub controls main page logic for form submissions, etc.
%>


<html>
<head>
  <title>Apprentice Trades - Online Survey</title>
  <link rel="stylesheet" title="nn v4.x styles" href="/global.displaynn.css" media="screen">
  <style type="text/css">
    @import url(/global.display.css);
  </style>

<script src="/globalincludes/global.routines.js.inc" language="javascript" type="text/javascript"></script>

<script language="javascript">

  function SubmitForm(mode)
  {
    var form = window.document.form1;

        switch (mode)
        {
           case "SAVESURVEY":
             
              form.userAction.value = mode;
              break;
        }
   
        form.submit();
  }



</script>


<style type="text/css">
  p { font-size: 16px; }
  td { font-size: 11px; }

</style>

</head>
<body bgcolor="#FFFFFF">

<h3><center>www.apprenticetrades.ca - Online Survey</center></h3>



<%= strMsgToUser %>


<%

if bDisplayForm then

%>

<p><strong>Description:</strong>
The <a href="http://www.apprenticetrades.ca" target="_blank">www.apprenticetrades.ca</a> web site is a one-stop source of Canadian apprenticeship information
</p>

<p><strong>Instructions:</strong>
Please take a few minutes fill out the survey below.  Your comments will help us to
improve the site.</p>

<p><b>Remember to submit your answers by pressing the "submit" button at
the end of the survey.</b></p>

<p>
  <center><img src="/images/color_frame.gif" width="97%" height="1" hspace="0" vspace="0"></center>
</p>


<p>
<b>General Information</b>
</p>

<form name="form1" action="default.asp" method="post">
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td valign="top">1.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Please select the Province/Territory in which you reside:
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="5" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <SELECT id=selQ1 name=selQ1>
            <OPTION value="">Select One</OPTION>
            <OPTION value="1">Alberta</OPTION>
            <OPTION value="2">British Columbia</OPTION>
            <OPTION value="3">Manitoba</OPTION>
            <OPTION value="4">New Brunswick</OPTION>
            <OPTION value="5">Newfoundland</OPTION>
            <OPTION value="6">Nova Scotia</OPTION>
            <OPTION value="7">Nunavut</OPTION>
            <OPTION value="8">Northwest Territories</OPTION>
            <OPTION value="9">Ontario</OPTION>
            <OPTION value="10">Prince Edward Island</OPTION>
            <OPTION value="11">Quebec</OPTION>
            <OPTION value="12">Saskatchewan</OPTION>
            <OPTION value="13">Yukon</OPTION>
          </SELECT>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>

    <tr>
      <td valign="top">2.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Please select which best describes you:
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="5" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <SELECT id=selQ2 name=selQ2>
            <OPTION value="">Select One</OPTION>
            <OPTION value="1">Student</OPTION>
            <OPTION value="2">Young Adult</OPTION>
            <OPTION value="3">Apprentice</OPTION>
            <OPTION value="4">Journeyperson</OPTION>
            <OPTION value="5">Teacher / Guidance Counsellor</OPTION>
            <OPTION value="6">Instructor</OPTION>
            <OPTION value="7">Parent</OPTION>
            <OPTION value="8">Employer</OPTION>
            <OPTION value="9">Equity Seeking Group</OPTION>
            <OPTION value="10">Inventory Project Steering Committee Member</OPTION>
            <OPTION value="11">CAF-FCA Board Member</OPTION>
            <OPTION value="12">From an Employer Association</OPTION>
            <OPTION value="13">From a Labour Organization</OPTION>
            <OPTION value="14">From a Government Organization</OPTION>
            <OPTION value="15">Other</OPTION>

           
          </SELECT>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>

    <tr>
      <td valign="top">3.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          How would you describe yourself when it comes to using the Internet?
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ3 name=radQ3 value="1">Beginner
          <INPUT type="radio" id=radQ3 name=radQ3 value="2">Intermediate
          <INPUT type="radio" id=radQ3 name=radQ3 value="3">Advanced
         
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>

    <tr>
      <td valign="top">4.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Which type of computer are you using?
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ4 name=radQ4 value="2">PC
          <INPUT type="radio" id=radQ4 name=radQ4 value="1">Mac
          <INPUT type="radio" id=radQ4 name=radQ4 value="3">Unsure
         
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>

    <tr>
      <td valign="top">5.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Which Web Browser are you currently using to review the www.apprenticetrades.com website?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ5 name=radQ5 value="1">Netscape Navigator
          <INPUT type="radio" id=radQ5 name=radQ5 value="2">Internet Explorer
          <INPUT type="radio" id=radQ5 name=radQ5 value="3">Opera
          <INPUT type="radio" id=radQ5 name=radQ5 value="4">Other
          <INPUT type="radio" id=radQ5 name=radQ5 value="5">Unsure
         
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>


    <tr>
      <td valign="top">6.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Which version of web browser are you using?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ6 name=radQ6 value="1" >Version 3 or less
          <INPUT type="radio" id=radQ6 name=radQ6 value="2" >Version 4
          <INPUT type="radio" id=radQ6 name=radQ6 value="3">Version 5
          <INPUT type="radio" id=radQ6 name=radQ6 value="4">Version 6
          <INPUT type="radio" id=radQ6 name=radQ6 value="5">Version 7
          <INPUT type="radio" id=radQ6 name=radQ6 value="6">Unsure
         
      </td>
    </tr>
   
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="40" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <b>Targeted Content Pages</b><br>
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="10" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
   

    <tr>
      <td valign="top">7.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">On the left hand side of the site there is a list of potential visitors to the website. If you clicked on one of these while exploring the site, please select it in the list below and answer questions 8 & 9 relating to that section of the website. If you did not click on one of these while exploring the site, please skip questions 7, 8 & 9 and go to question 10.

           
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="5" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <SELECT id=selQ7 name=selQ7>
            <OPTION value="">Select One</OPTION>
            <OPTION value="1">Students</OPTION>
            <OPTION value="2">Young Adults</OPTION>
            <OPTION value="3">Apprentices</OPTION>
            <OPTION value="4">Journeypersons</OPTION>
            <OPTION value="5">Teachers / Guidance Counsellors</OPTION>
            <OPTION value="6">Instructors</OPTION>
            <OPTION value="7">Parents</OPTION>
            <OPTION value="8">Employers</OPTION>
            <OPTION value="9">Equity Seeking Groups</OPTION>
           
          </SELECT>
         
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
   

    <tr>
      <td valign="top">8.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Was the information provided relevant to the group you selected?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ8 name=radQ8 value="1" >The information was very relevant to the group selected<br>
          <INPUT type="radio" id=radQ8 name=radQ8 value="2">The information was somewhat relevant to the group selected<br>
          <INPUT type="radio" id=radQ8 name=radQ8 value="3">The information was not relevant to the information selected
         
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>


    <tr>
      <td valign="top">9.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          How would you rate the amount of information provided for the group you selected?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ9 name=radQ9 value="1" >Not enough information was provided<br>
          <INPUT type="radio" id=radQ9 name=radQ9 value="2">An adequate amount of information was provided<br>
          <INPUT type="radio" id=radQ9 name=radQ9 value="3">Too much information was provided
      </td>
    </tr>
   
   
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="40" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <b>Information Finder</b><br>
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="10" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>


    <tr>
      <td valign="top">10.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          How would you rate the usability of the Information Finder?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ10 name=radQ10 value="1" >Very easy to use
          <INPUT type="radio" id=radQ10 name=radQ10 value="2">Somewhat easy to use
          <INPUT type="radio" id=radQ10 name=radQ10 value="3">Somewhat difficult to use
          <INPUT type="radio" id=radQ10 name=radQ10 value="4">Very difficult to use
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
   

    <tr>
      <td valign="top">11.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Were the search results produced by the Information Finder relevant to what you were searching for?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ11 name=radQ11 value="1" >The search results were very relevant<br>
          <INPUT type="radio" id=radQ11 name=radQ11 value="2">The search results were somewhat relevant<br>
          <INPUT type="radio" id=radQ11 name=radQ11 value="3">The search results were not relevant
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="40" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <b>Information on the Web Site</b><br>
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="10" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>


    <tr>
      <td valign="top">12.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          There are a number of featured "articles" within this website.  Please check off which articles you read while exploring the web site and answer the questions associated with that article.    
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="8" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>

    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
           Article: Frequently Asked Questions
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="right" valign="top" width="15">
        &nbsp;&nbsp;&nbsp;&nbsp;
      </td>
      <td align="left" valign="top">
          <INPUT type="radio" id=radQ12A name=radQ12A value="1">This article was clearly written and easy to read<br>
          <INPUT type="radio" id=radQ12A name=radQ12A value="2">This article was not clearly written and was difficult to read. Please comment why:<br>
          <TEXTAREA rows=2 cols=60 id=txtQ12A name=txtQ12A></TEXTAREA>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="8" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>

    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
           The Cost of Apprenticeship
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="right" valign="top" width="15">
        &nbsp;&nbsp;&nbsp;&nbsp;
      </td>
      <td align="left" valign="top">
          <INPUT type="radio" id=radQ12B name=radQ12B value="1">This article was clearly written and easy to read<br>
          <INPUT type="radio" id=radQ12B name=radQ12B value="2">This article was not clearly written and was difficult to read. Please comment why:<br>
          <TEXTAREA rows=2 cols=60 id=txtQ12B name=txtQ12B></TEXTAREA>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="8" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>

    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
           Tips for Employers
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="right" valign="top" width="15">
        &nbsp;&nbsp;&nbsp;&nbsp;
      </td>
      <td align="left" valign="top">
          <INPUT type="radio" id=radQ12C name=radQ12C value="1">This article was clearly written and easy to read<br>
          <INPUT type="radio" id=radQ12C name=radQ12C value="2">This article was not clearly written and was difficult to read. Please comment why:<br>
          <TEXTAREA rows=2 cols=60 id=txtQ12C name=txtQ12C></TEXTAREA>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="8" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>

    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
           Starting a Career
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="right" valign="top" width="15">
        &nbsp;&nbsp;&nbsp;&nbsp;
      </td>
      <td align="left" valign="top">
          <INPUT type="radio" id=radQ12D name=radQ12D value="1">This article was clearly written and easy to read<br>
          <INPUT type="radio" id=radQ12D name=radQ12D value="2">This article was not clearly written and was difficult to read. Please comment why:<br>
          <TEXTAREA rows=2 cols=60 id=txtQ12D name=txtQ12D></TEXTAREA>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="8" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>


    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
           The Basics
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="right" valign="top" width="15">
        &nbsp;&nbsp;&nbsp;&nbsp;
      </td>
      <td align="left" valign="top">
          <INPUT type="radio" id=radQ12E name=radQ12E value="1">This article was clearly written and easy to read<br>
          <INPUT type="radio" id=radQ12E name=radQ12E value="2">This article was not clearly written and was difficult to read. Please comment why:<br>
          <TEXTAREA rows=2 cols=60 id=txtQ12E name=txtQ12E></TEXTAREA>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="8" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>


    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
           A Ticket To Canada
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="right" valign="top" width="15">
        &nbsp;&nbsp;&nbsp;&nbsp;
      </td>
      <td align="left" valign="top">
          <INPUT type="radio" id=radQ12F name=radQ12F value="1">This article was clearly written and easy to read<br>
          <INPUT type="radio" id=radQ12F name=radQ12F value="2">This article was not clearly written and was difficult to read. Please comment why:<br>
          <TEXTAREA rows=2 cols=60 id=txtQ12F name=txtQ12F></TEXTAREA>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="40" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <b>Overall Satisfaction</b><br>
      </td>
    </tr>
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="10" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>


    <tr>
      <td valign="top">13.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Overall, did you find this website:  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ13 name=radQ13 value="1" >Very easy to navigate (very easy to use)<br>
          <INPUT type="radio" id=radQ13 name=radQ13 value="2">Somewhat easy to navigate (somewhat easy to use)<br>
          <INPUT type="radio" id=radQ13 name=radQ13 value="3">Somewhat difficult to navigate (somewhat difficult to use)<br>
          <INPUT type="radio" id=radQ13 name=radQ13 value="4">Very difficult to navigate (very difficult to use)
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>    

    <tr>
      <td valign="top">14.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Would you consider using this website in the future as a resource for apprenticeship information?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ14 name=radQ14 value="1" >Yes
          <INPUT type="radio" id=radQ14 name=radQ14 value="2">No
          <INPUT type="radio" id=radQ14 name=radQ14 value="3">Maybe
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>  


    <tr>
      <td valign="top">15.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Would you recommend this website to others as a good resource for apprenticeship information?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ15 name=radQ15 value="1" >Yes
          <INPUT type="radio" id=radQ15 name=radQ15 value="2">No
          <INPUT type="radio" id=radQ15 name=radQ15 value="3">Maybe
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="15" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>    


    <tr>
      <td valign="top">16.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Do you have any comments or suggestions to improve the website?  Be as general or specific as you wish.  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <TEXTAREA rows=4 cols=60 id=txtQ16 name=txtQ16></TEXTAREA>
      </td>
    </tr>
   
    <tr>
      <td colspan="3">
        <img src="<% spacer() %>" width="1" height="20" hspace="0" vspace="0" alt=""><br>
      </td>
    </tr>  
   
       <tr>
      <td colspan="3" valign="top" align="center">Thank you for taking the time to complete this survey.</td>
    </tr>
                       
  </table>
 
 
  <input type="hidden" name="userAction" value="">
 
 

<p align=center>
  <input type="button" onclick="javascript:SubmitForm('SAVESURVEY');" value="Submit Survey" id=butSubmit name=butSubmit>
</p>
</form>

<%
else
%>

<br>
<p align=center>
The Canadian Apprenticeship Forum - Forum canadien sur l'apprentissage would like to thank you for taking the time to complete this survey.
</p>

<%
end if
%>

<p>
<center><a href="javascript:window.close();self.close();">Close Window</a></center>
</p>

<%
if blnDebug then
  writeln "<br><br><br>===========  DEBUG INFO ================<br><br>"
  writeln strDebug
end if
%>


</body>
</html>






<%
'------------------------------------------------------------------------------
' BEGIN Server-side functions
' -----------------------------------------------------------------------------
sub Main()
    CreateGlobalObjects
   
    Dim strAction, strConfirm
    strAction = rq("userAction")
    strConfirm = rq("confirm")
   
    select case strAction
        case "SAVESURVEY":
           
                  call SaveSurveyResponse()
                  
            if bDisplayForm = false then
                'this will avoid resubmitting the form if browser reload button is pressed
                Response.Redirect "default.asp?confirm=1"
            end if    
       
        case else
            if strConfirm = "1" then
                bDisplayForm = false
                        
                FormatMsgToUser "Your survey results were successfully saved.  Thank-you."
                        
                        
   dim objMail, msgto
   set objMail=server.CreateObject("CDONTS.NewMail")
   objMail.To="elie_azzi@caf-fca.org"                'set TO address
   objMail.from="elie_azzi@caf-fca.org"            'set FROM address
   objMail.value("reply-to") ="elie_azzi@caf-fca.org" 'set reply to address
   objMail.subject="testmsgsubject"       'set the subject line
   objMail.body="sstr"                 'set the message content  
   objMail.send                       'send the message
   set objMail=nothing                'destroy the component
   'Response.Write "done"
   
                        
            else
                bDisplayForm = true
            end if
    end select

    CleanUpGlobalObjects

end sub


sub CreateGlobalObjects
    on error resume next
    set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open ConnectString
   
end sub


sub CleanUpGlobalObjects
    on error resume next
    if oConn.state = 1 then
        oConn.close
    end if
    set oConn = nothing
end sub


sub SaveSurveyResponse()
    on error resume next
    dim strSQL, iRecordsAffected, adoRS, iResponseID, strSQL2, strBaseSQL
    iRecordsAffected = 0
   
   

    strSQL = "INSERT INTO SUR_Responses (DateEntered) VALUES ('" & now() & "')"

    oConn.Execute strSQL, iRecordsAffected
   
    set adoRS = Server.CreateObject("ADODB.RecordSet")
    Set adoRS = oConn.Execute("SELECT @@IDENTITY")
   
    if not (adoRS.EOF or adoRS.BOF) then
        iResponseID = adoRS(0)
    end if
   
    if err.number = 0 then
        strBaseSQL = "INSERT INTO SUR_ResponsesAnswers (ResponseID, QuestionNo, QuestionPartNo, AnswerID, Comment) " & _
                      "VALUES (" & iResponseID & ","
   
        strSQL2 = strBaseSQL & "1,0," & FormatSurveyOptionForDB(rq("selQ1")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "2,0," & FormatSurveyOptionForDB(rq("selQ2")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "3,0," & FormatSurveyOptionForDB(rq("radQ3")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "4,0," & FormatSurveyOptionForDB(rq("radQ4")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "5,0," & FormatSurveyOptionForDB(rq("radQ5")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "6,0," & FormatSurveyOptionForDB(rq("radQ6")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "7,0," & FormatSurveyOptionForDB(rq("selQ7")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "8,0," & FormatSurveyOptionForDB(rq("radQ8")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "9,0," & FormatSurveyOptionForDB(rq("radQ9")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "10,0," & FormatSurveyOptionForDB(rq("radQ10")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "11,0," & FormatSurveyOptionForDB(rq("radQ11")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,1," & FormatSurveyOptionForDB(rq("radQ12A")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12A")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,2," & FormatSurveyOptionForDB(rq("radQ12B")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12B")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,3," & FormatSurveyOptionForDB(rq("radQ12C")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12C")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,4," & FormatSurveyOptionForDB(rq("radQ12D")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12D")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,5," & FormatSurveyOptionForDB(rq("radQ12E")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12E")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "12,6," & FormatSurveyOptionForDB(rq("radQ12F")) & ",'" & FormatSurveyCommentForDB(rq("txtQ12F")) & "')" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "13,0," & FormatSurveyOptionForDB(rq("radQ13")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "14,0," & FormatSurveyOptionForDB(rq("radQ14")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "15,0," & FormatSurveyOptionForDB(rq("radQ15")) & ",NULL)" & vbCrLf
        strSQL2 = strSQL2 & strBaseSQL & "16,0,0,'" & FormatSurveyCommentForDB(rq("txtQ16")) & "')" & vbCrLf
       
                 
        oConn.Execute strSQL2, iRecordsAffected
       
        if err.number = 0 then
            bDisplayForm = false
        else
            bDisplayForm = true
            FormatMsgToUser "An error occurred while processing your request.  Please try again later."
            AddToDebugString "Error:SaveSurveyResponse(): " & err.number & " - " & err.Description, true
        end if
   
    else
        bDisplayForm = true
        FormatMsgToUser "An error occurred while processing your request.  Please try again later."
        AddToDebugString "Error:SaveSurveyResponse(): " & err.number & " - " & err.Description, true
    end if
   

    if blnDebug then
        AddToDebugString "strSQL=" & strSQL, true
        AddToDebugString "strSQL2=" & strSQL2, false
        AddToDebugString "iResponseID=" & iResponseID, false
        AddToDebugString "iRecordsAffected=" & iRecordsAffected, false
    end if
   
    if adoRS.State = 1 then
        adoRS.Close
    end if
    set adoRS = nothing
   
end sub

function FormatSurveyCommentForDB(str)
    if str <> "" then
        str = replace(str,"'","''")
    end if
    FormatSurveyCommentForDB = str
end function

function FormatSurveyOptionForDB(str)
    'used to manipulate text input for datbase storage
    if str = "" then
        str = "0"
    end if
    FormatSurveyOptionForDB = str
end function

'------------------------------------------------------------------------------
' END Server-side functions
' -----------------------------------------------------------------------------
%>
Sorry, that was a typo on my side--I meant to say:

objMail.body=Request.Form("txtQ16")

FtB
I did it didn't work... the email come empty without any txt16.

So I've changed to this ObjMailBody for this one: this is comment number 16: ("txtQ16)... Also didn't work.
Fo your information this code is at the buttom of the page... Pls. advice. thankyou.

dim objMail, msgto
   set objMail=server.CreateObject("CDONTS.NewMail")
   objMail.To="elie_azzi@caf-fca.org"                'set TO address
   objMail.from="elie_azzi@caf-fca.org"            'set FROM address
   objMail.value("reply-to") ="elie_azzi@caf-fca.org" 'set reply to address
   objMail.body="This is text 16:"Request.Form("txtQ16")
   objMail.send                       'send the message
   set objMail=nothing                'destroy the component
   'Response.Write "done"   <TEXTAREA rows=4 cols=60 id=txtQ16 name=txtQ16></TEXTAREA>
   
            else
                bDisplayForm = true
            end if
    end select

    CleanUpGlobalObjects

end sub
For troubleshooting, replace this:

objMail.body="This is text 16:"Request.Form("txtQ16")


with:

objMail.body="This is text 16:" & Request.Form("txtQ16")


FtB
No Error, in the email I got :


This is text 16:


I didn't get the TXTQ16. field... Pls. advice any idea.
I am having a hard time following your application flow....I am tyring to see where the email routine gets called and to determine if you can access the request.form objects there or not.

FtB
This is true... AS you can see all the code is on the same page.  but I'm not sure where I should put this small code in my full code above.

   dim objMail, msgto
   set objMail=server.CreateObject("CDONTS.NewMail")
   objMail.To="elie_azzi@caf-fca.org"                'set TO address
   objMail.from="elie_azzi@caf-fca.org"            'set FROM address
   objMail.value("reply-to") ="elie_azzi@caf-fca.org" 'set reply to address
   objMail.body="This is text 16:" & Request.Form("txtQ16")
   objMail.send                       'send the message
   set objMail=nothing                'destroy the component
   'Response.Write "done"   <TEXTAREA rows=4 cols=60 id=txtQ16 name=txtQ16></TEXTAREA>

Thank you
Elie.
you probably have your form using the GET method.
just change your code to:    request("txtQ16")

then it won't matter whether your form is set with GET or POST
@gotaluvme--

>>you probably have your form using the GET method.<<

If you look at the code, the method is indeed POST--

<form name="form1" action="default.asp" method="post">

FtB
Okay, let's see if we can make sense of this. The page posts to itself, right? Is the name of this page default.asp?

FtB
yes
FYI, I've put the code at the top of the page.

So when i load the url, an email will be sent as:

This is text 16:

Then a second email after i fill the field: Elie then submit
this is text 16: elie

then a third email:
this is text 16.

So the question is where we should put it on the code exactly... do you see what i means.
thank you bro... Pls. advice.
ASKER CERTIFIED SOLUTION
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi FTP,

I copied the code and it's not pickup up the data in this field.

It's showing:
TextThis is text 16:

Cheers,
Okay. Next step--

I don't understand this:

 Dim strAction, strConfirm
    strAction = rq("userAction")
    strConfirm = rq("confirm")

shouldn't that be:

Dim strAction, strConfirm
    strAction = Request("userAction")
    strConfirm = Request("confirm")

It's working ... Thank you VERY MUCH ! I've deplace the code after the call SaveSurvey.

One others question is there a way I can add more

  objMail.body="This is text 16:" & Request.Form("txtQ16")

Then I want a <BR> and I want to have txtQ15, and txt14. but  a BR line between them?

Tks.




select case strAction
        case "SAVESURVEY":
           
               call SaveSurveyResponse()
               dim objMail, msgto
   set objMail=server.CreateObject("CDONTS.NewMail")
   objMail.To="elie_azzi@caf-fca.org"                'set TO address
   objMail.from="elie_azzi@caf-fca.org"            'set FROM address
   objMail.value("reply-to") ="elie_azzi@caf-fca.org" 'set reply to address
   objMail.subject="testmsgsubject"       'set the subject line
  objMail.body="This is text 16:" & Request.Form("txtQ16")
   objMail.send                       'send the message
   set objMail=nothing                'destroy the component
   'Response.Write "done"
To add lines, try:

="This is text 16:" & VBCrLf & Request.Form("txtQ16")

FtB
It's WORKING I'm very happy, before I end. one more question since you're the BEST expert. Thank you god bless you!

   objMail.body="Do you have any comments or suggestions to improve:" & VBCrLf & Request.Form("txtQ16")  & VBCrLf & Request.Form("radQ15")

So instead in the email showing 1 2, 3, I'd like to show 1 -> yes, 2 --> no and 3 maybe.
How I can improve the previous line above.


For Question 15:. (Random quesiton).
15.   Would you recommend this website to others as a good resource for apprenticeship information?  
         () Yes    () No     ()Maybe  


This is the ASP code:

tr>
      <td valign="top">15.&nbsp;&nbsp;</td>
      <td align="left" colspan="2">
          Would you recommend this website to others as a good resource for apprenticeship information?  
      </td>
    </tr>
    <tr>
      <td align="right" valign="top" width="5">&nbsp;
       
      </td>
      <td align="left" valign="top" colspan="2">
          <INPUT type="radio" id=radQ15 name=radQ15 value="1" >Yes
          <INPUT type="radio" id=radQ15 name=radQ15 value="2">No
          <INPUT type="radio" id=radQ15 name=radQ15 value="3">Maybe
      </td>
    </tr>
If Request.Form("radQ15") ="1" then
  strRecommend = "Yes"
elseif Request.Form("radQ15") ="2" then
  strRecommend = "Yes"
else
  strRecommend = "Maybe"
end if


objMail.body="Do you have any comments or suggestions to improve:" & VBCrLf & Request.Form("txtQ16")  & VBCrLf & strRecommend

Antything for a fellow Canadian,

FtB
You can see this in a new question in ASP.
Glad to have helped,

FtB