Howdy, I'm having a lot of trouble with my aspmailer which I use to send a form as an email through our internal email server. As far as I can see the asp works fine right up until it needs to send the email. I've trialled it with various email destinations and on both our wan and my local webserver.
What happens: User goes to test.asp and fills out their name and does the test. They press 'submit' which sends the information to aspmailer.asp (which I can see is working because the url redirect works) however the data is not being sent to the webserver.
Any idea why this form isn't working?
Here is my complete (form code) of test.asp . P.S. It's a medical test just fyi.
And here is the aspmailer.asp
What happens: User goes to test.asp and fills out their name and does the test. They press 'submit' which sends the information to aspmailer.asp (which I can see is working because the url redirect works) however the data is not being sent to the webserver.
Any idea why this form isn't working?
Here is my complete (form code) of test.asp . P.S. It's a medical test just fyi.
Code:
<form name="quiz" action="aspmailer.asp" method="POST">
<!-- If you want to change who the email is sent to once the "Submit" Button is pressed go to the above file (currently ../cgi-bin/aspmailer.asp and look for the line "strRcpt = "someone@something.org.au" 'Put the address you want the form sent to here" and change someone@something.org.au to the desired target email address.-->
<!--fields used to direct asp script actions-->
<!--TGrequire: fields that must have input [OPTIONAL]-->
<input type="hidden" name="TGrequire" value="Name: ">
<!--TGorder: order in which inputs should appear in email [OPTIONAL]-->
<input type="hidden" name="TGorder" value="Name: ,PayCode: ,Department: ,Test Number: ,Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,Q10,Q11,Q12,SCORE,Out Of: ">
<!--TGsubject: Subject line of email [OPTIONAL]-->
<input type="hidden" name="TGsubject" value="Someone has completed the Online Nursing Maths Test">
<!--TGredirect: URL browser can be redirected to on successful submission [OPTIONAL]-->
<input type="hidden" name="TGredirect" value="">
<input type="hidden" name="Out Of: " value="12">
<input type="hidden" name="Test Number: " value="2">
<hr>
<div align="left">
<table width="85%" border="0">
<tr>
<td height="2178">
<div align="left">
<table width="80%" border="0" cellpadding="0">
<tr>
<td class="body" colspan="2" bgcolor="#C9E4E4">
<p><font color="#CC6633" face="Geneva, Arial, Helvetica, san-serif"></font></p>
</td>
</tr>
<tr>
<td class="body" width="25%">
<div align="right"><font face="Georgia, Times New Roman, Times, serif"><b>
Name: </b></font></div>
</td>
<td class="body" width="75%">
<input name="Name: " size="30" onFocus="if(disabled)blur();">
</td>
</tr>
<tr>
<td class="body" width="25%">
<div align="right"><font face="Georgia, Times New Roman, Times, serif"><b>
PayCode: </b></font></div>
</td>
<td class="body" width="75%">
<input type="text" name="PayCode: " size="12">
</td>
</tr>
<tr>
<td class="body" width="25%">
<div align="right"><font face="Georgia, Times New Roman, Times, serif"><b>Department</b></font></div>
</td>
<td class="body" width="75%">
</td>
</tr>
<tr>
<td class="body" colspan="2" bgcolor="#C9E4E4"></td>
</tr>
<tr>
<td class="body" colspan="2">
<p>PLEASE COMPLETE THE FOLLOWING QUESTIONS CALCULATORS MAY
BE USED TO CHECK ANSWERS CHOOSE THE CORRECT FORMULA AND
ANSWER. </p>
<p> </p>
<p> </p>
</td>
</tr>
</table>
<p align="center"><b><font color="#990000" face="Georgia, Times New Roman, Times, serif">Please
enter your name BEFORE starting the test.</font></b></p>
<p align="center"><font color="#990000"><b><font face="Georgia, Times New Roman, Times, serif">Please
do not print this test.<font size="2"></font></font></b></font></p>
<p><a href="formulas.jpg" onMouseDown="MM_openBrWindow('formulas.jpg','Formulas','width=607,height=380')" target="_new">Click
Here for Formulas</a></p>
<br>
<p><b>1. Thyroxine is prescribed to be given 150 micrograms daily.Tablets
are available in 0.05 mgs.How many tablets do you give?</b><br>
<input type="radio" name="Q1" onClick="this.form['Name: '].disabled=true"; Q1.value="A" VALUE="5">
a) 5<br>
<input type="radio" name="Q1" onClick="this.form['Name: '].disabled=true"; Q1.value="B" VALUE="2">
b) 2<br>
<input type="radio" name="Q1" onClick="this.form['Name: '].disabled=true"; Q1.value="*" VALUE="* 3">
c) 3<br>
<input type="radio" name="Q1" onClick="this.form['Name: '].disabled=true"; Q1.value="D" VALUE="1/3">
d) <img src="formula02.jpg" width="13" height="18"> </p>
</div>
<p>
<p align="left"><b> 2. Digoxin 0.125 mg is ordered to be given orally.Tablets
available are 62.5 micrograms.How many tablets do you give?</b><br>
<input type="radio" name="Q2" VALUE=" * 2" onClick=Q2.value="*">
a) 2<br>
<input type="radio" name="Q2" VALUE="1" onClick=Q2.value="B">
b) 1<br>
<input type="radio" name="Q2" VALUE="1/2" onClick=Q2.value="C">
c) ½<br>
<input type="radio" name="Q2" VALUE="4" onClick=Q2.value="D">
d) 4
<p align="left"><b>3. A child weighing 10 kgs has been ordered Phenergan
elixir 0.5 mgs per kg bodyweight. The drug is available as 5 mgs
in 5 mls.How much mixture would you give?</b><br>
<input type="radio" name="Q3" VALUE="2.5" onClick=Q3.value="A">
a) 2.5<br>
<input type="radio" name="Q3" VALUE="10" onClick=Q3.value="B">
b) 10<br>
<input type="radio" name="Q3" VALUE="1" onClick=Q3.value="C">
c) 1<br>
<input type="radio" name="Q3" VALUE="* 5" onClick=Q3.value="*">
d) 5
<p align="left"><b>4. Mr chesty is ordered Atropine 0.4 mgs IMI as
part of his Pre medication.The ampoule contains 1200 micrograms
per ml.What volume would you give?</b><br>
<input type="radio" name="Q4" VALUE="* 1.2" onClick=Q4.value="*">
1.2<br>
<input type="radio" name="Q4" VALUE="3" onClick=Q4.value="B">
3<br>
<input type="radio" name="Q4" VALUE="0.3" onClick=Q4.value="C">
0.3 <br>
<input type="radio" name="Q4" VALUE="0.4" onClick=Q4.value="D">
0.4
<p align="left">
<p align="left"><b>5. 500 mls of IVI fluid is to be given over 2 hours.The
IV giving set delivers 20 drops per ml (macro set)How many drops
per minute should you count?</b><br>
<input type="radio" name="Q5" VALUE="* 84" onClick=Q5.value="*">
84<br>
<input type="radio" name="Q5" VALUE="125" onClick=Q5.value="B">
125<br>
<input type="radio" name="Q5" VALUE="250" onClick=Q5.value="C">
250 <br>
<input type="radio" name="Q5" VALUE="42" onClick=Q5.value="D">
42
<p align="left"><b>6. The micro infusion set delivers 60 drops of
fluid per ml.1000 mls of fluid is to be given over 6 hour.How many
drops per minute are counted?</b><br>
<p align="left">
<input type="radio" name="Q6" VALUE="60" onClick=Q6.value="A">
60 <br>
<input type="radio" name="Q6" VALUE="* 84" onClick=Q6.value="*">
84<br>
<input type="radio" name="Q6" VALUE="167" onClick=Q6.value="C">
167<br>
<input type="radio" name="Q6" VALUE="12" onClick=Q6.value="D">
12
<p align="left"><b>7. A patient is ordered 1.8 gms of IVI benzylpenicillin.The
vial contains 3 grams. Using the scale provided, calculateHow many
mls of solution you will administer to the patient.All 3 alternative
answers are provided.</b></p>
<p align="center"><b><img src="formula01.jpg" width="374" height="48"></b></p>
<p align="left">
<input type="radio" name="Q7" VALUE="10, 9, 3mls" onClick=Q7.value="A">
10, 9, 3mls<br>
<input type="radio" name="Q7" VALUE="15, 10, 6 mls" onClick=Q7.value="B">
15, 10, 6 mls<br>
<input type="radio" name="Q7" VALUE="18, 13, 8 mls" onClick=Q7.value="C">
18, 13, 8 mls<br>
<input type="radio" name="Q7" VALUE="* 12, 9, 6mls" onClick=Q7.value="*">
12, 9, 6mls</p>
<p align="left">
<table width="100%" border="0">
<tr>
<td bgcolor="#CCCCCC"> </td>
</tr>
</table>
<p align="left">
<p align="center"><b>Policy questions</b></p>
<p><b><a href="[URL unfurl="true"]http://sandocs.sah.com/toc_section.asp?Dept=PHA&Manual=DRG&Section=all"[/URL] target="_new">Click
Here for the Pharmacy Drug Therapy Manual</a></b></p>
<p align="left">
<p align="left"><b>Choose the correct answer for each abbreviation:</b>
<blockquote>
<table width="100%" border="0">
<tr>
<td width="28%"><b>8.)</b> p.c. </td>
<td width="62%">
<input type="radio" name="Q8" VALUE="before meals" onClick=Q8.value="A">
before meals
<input type="radio" name="Q8" VALUE="* after meals" onClick=Q8.value="*">
after meals
<input type="radio" name="Q8" VALUE="after medication" onClick=Q8.value="C">
after medication
<input type="radio" name="Q8" VALUE="before medication" onClick=Q8.value="D">
before medication
</td>
<td width="10%"> </td>
</tr>
<tr>
<td width="28%"><b>9.)</b> qid</td>
<td width="62%">
<input type="radio" name="Q9" VALUE="* 4 times a day" onClick=Q9.value="*">
4 times a day
<input type="radio" name="Q9" VALUE="every 4 hours" onClick=Q9.value="B">
every 4 hours
<input type="radio" name="Q9" VALUE="every 2 hours" onClick=Q9.value="C">
every 2 hours
<input type="radio" name="Q9" VALUE="2 times a day" onClick=Q9.value="D">
2 times a day</td>
<td width="10%"> </td>
</tr>
<tr>
<td width="28%"><b>10.) </b> o.d.</td>
<td width="62%">
<input type="radio" name="Q10" VALUE="* every day" onClick=Q10.value="*">
every day
<input type="radio" name="Q10" VALUE="oral drops" onClick=Q10.value="B">
oral drops
<input type="radio" name="Q10" VALUE="overdose" onClick=Q10.value="C">
overdose
<input type="radio" name="Q10" VALUE="discontinued" onClick=Q10.value="D">
discontinued</td>
<td width="10%"> </td>
</tr>
</table>
</blockquote>
<p align="left"><br>
<p align="left"><b>11. You are asked to deliver 1000 mls of Dextrose
saline IVI with 40 mmols of Potassium chloride over 12 hours.Your
patient has a central line. Do you require an infusion pump?</b><br>
<p align="left">
<input type="radio" name="Q11" VALUE="*">
yes<br>
<input type="radio" name="Q11" VALUE="">
no <br>
<input type="radio" name="Q11" VALUE="">
only for elderly patients<br>
<input type="radio" name="Q11" VALUE="">
not for obstetric patients<br>
<p align="left">
<p align="left"> <b>12</b>,<b> Choose the SAH approved drug references
to confirm correct medication administration.</b><br>
<p align="left">
<input type="radio" name="Q12" VALUE="Pharmacist, NUM" onClick=Q12.value="A">
Pharmacist, NUM<br>
<input type="radio" name="Q12" VALUE="MIMS, Senior RN" onClick=Q12.value="B">
MIMS, Senior RN <br>
<input type="radio" name="Q12" VALUE="Pharmacist, CMO" onClick=Q12.value="C">
Pharmacist, CMO <br>
<input type="radio" name="Q12" VALUE="* MIMS, gold book, pharmacist,drug insert." onClick=Q12.value="*">
MIMS, gold book, pharmacist,drug insert.
<p align="left"><font color="#990000"><b><font size="4">Please make
sure you have entered your Name and Paycode Before Sending Results</font><br>
</b></font><br>
<table border="0" align="center">
<tr>
<td valign="middle">
<input type="button" value="Score Quiz" onClick=scorequiz(this.form) name="button">
</td>
<td valign="bottom"><a href="#top"><img src="reviewTest.jpg" width="83" height="24" border="0"></a></td>
</tr>
</table>
<p align="center">
<center>
<p><B>Your Quiz Score is </B>
<INPUT NAME="SCORE" TYPE="text" maxlength="2" size="5" READONLY>
<b> out of 12</b></p>
<p>
<input type="submit" value="Submit Test" name="submit">
</p>
</center>
<p>
<center>
</center>
</td>
</tr>
</table>
<p> </p>
<p> </p>
</div>
<p>
</FORM>
And here is the aspmailer.asp
Code:
<%@language = "VBscript"%>
<%
'Tom Germain's Standard Cgiware Global Variables and set-up
'DO NOT REMOVE THIS SECTION OR NOTHING WILL WORK
Dim strError
Response.Buffer = True
If ScriptEngineMajorVersion < 2 Then
ReportError "Host system needs scripting engine upgrade to use this script"
End If
Set objFM = CreateObject("Scripting.Dictionary")
If IsObject(objFM) = False Then
ReportError "Host system lacks component(s) required by this script"
End If
Set objMailx = CreateObject("CDONTS.Newmail")
If IsObject(objMailx) = False Then
ReportError "Host system lacks component(s) required by this script"
End If
Set objMailx = Nothing
%>
<%
'aspmailer.asp by Tom Germain, Copyright 1998-2004
'Version 1.0
'cgiwaresoftware@yahoo.com
'Visit [URL unfurl="true"]http://www.cgiware.com[/URL] for latest version, documentation, and other resources
'This is freeware - Use at your own risk. No warranties provided.
'Redistribution of this program, in whole or in part, is strictly
'prohibited without the expressed written consent of the author.
'Custom programming available on hourly fee basis.
%>
<%'variables you can set start here%>
<%
strRcpt = "myemailaddress@me.com" 'Put the address you want the form sent to here
strFromVar = "" 'If you want a reply-to email address to be taken from the form
' put the name of the input item here.
strDefFrom = "User" 'Put a default, even fake, From address here
strDefSubject = "Form submitted" 'Put the subject of the letter here. If an input item called
'subject exists in the form, its value will be used instead.
strRedirect = "formsubmitted.html" 'Url to redirect to after a successful form submission. If an input item called
'redirect exists in the form, its value will be used instead.
%>
<%'variables you can set end here%>
<%
ParseForm
CheckForm
If Len(strError) > 0 Then
ReportError strError
End If
strOutX = SeqForm
If Len(strOutX) < 1 Then
strOutX = FormToString
End If
If Len(strOutX) < 1 Then
ReportError "Submitted form is empty"
End If
strSubject = strDefSubject
If objFM.Exists("TGsubject") Then
strSubject = objFM.Item("TGsubject")
End If
strFrom = strDefFrom
If Len(strFromVar) > 0 Then
If objFM.Exists(strFromVar) Then strFrom = objFM.Item(strFromVar) End If
End If
SendMail strFrom,strRcpt,strSubject,strOutX
If Len(strRedirect) > 0 Then
Response.redirect(strRedirect)
Response.End
End If
If objFM.Exists("TGredirect") = True Then
If Len(objFM.Item("TGredirect")) > 0 Then
Response.redirect(objFM.Item("TGredirect"))
Response.End
End If
End If
%>
<!--*******SUCCESSFUL SUBMISSION RESPONSE - START*******-->
<!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
<h1>Form Sent!</h1>
Your request has been received and will be processed shortly.
<!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->
<!--*******SUCCESSFUL SUBMISSION RESPONSE - END********-->
<%
Credit
Response.End
%>
<%
Function IsValidEmail(Email)
Dim Temp,Temp2
strNotValid = "<br>Email address not valid"
strTooLong = "<br>Email address too long"
If Len(Email) > 100 Then
ReportError strTooLong
End If
Email = LCase(Email)
Temp = Split(Email,"@",2,1)
If UBound(Temp) < 1 Then
ReportError strNotValid
End If
Temp2 = Split(Temp(1),".",-1,1)
If UBound(Temp2) < 1 Then
ReportError strNotValid
End If
End Function
%>
<%
Function SendMail(From,Rcpt,Subject,Body)
Trim(From)
Trim(Rcpt)
If Len(From) < 1 Then
ReportError strError & "<br>No Reply-to address (From) for this letter"
End If
If Len(Rcpt) < 1 Then
ReportError strError & "<br>No recipient for this letter"
End If
IsValidEmail Rcpt
IsValidEmail From
Set objMailer = CreateObject("CDONTS.Newmail")
objMailer.From = From
objMailer.To = Rcpt
objMailer.Subject = Subject
objMailer.Body = Body
objMailer.Send
Set objMailer = Nothing
End Function
%>
<%
Function CheckForm()
Dim Temp,strTmp,strForce
strInputReq = "<br>Input required for "
If objFM.Exists("TGrequire") = False Then
Exit Function
ElseIf isEmpty(objFM.Item("TGrequire")) Then
Exit Function
End If
strForce = objFM.Item("TGrequire")
Temp = Split(strForce,",",-1,1)
For Each strTmp in Temp
If objFM.Exists(strTmp) = False Then
strError = strError & strInputReq & strTmp
ElseIf Len(objFM.Item(strTmp)) < 1 Then
strError = strError & strInputReq & strTmp
End If
Next
End Function
%>
<%
Function ParseForm()
For Each Item in Request.Form
If objFM.Exists(Item) Then
objFM.Item(Item) = objFM.Item(Item) & "," & Request.QueryString(Item)
Else
objFM.Add Item,Request.Form(Item)
End If
Next
For Each Item in Request.QueryString
If objFM.Exists(Item) Then
objFM.Item(Item) = objFM.Item(Item) & "," & Request.QueryString(Item)
Else
objFM.Add Item,Request.QueryString(Item)
End If
Next
End Function
%>
<%
Function SeqForm()
Dim Temp,strTmp,strOrder,strOut
If objFM.Exists("TGorder") = False Then
Exit Function
ElseIf isEmpty(objFM.Item("TGorder")) Then
Exit Function
End If
strOrder = objFM.Item("TGorder")
Temp = Split(strOrder,",",-1,1)
For Each strTmp in Temp
If objFM.Exists(strTmp) Then
strOut = strOut & strTmp & "=" & objFM.Item(strTmp) & Chr(10)
End If
Next
SeqForm = strOut
End Function
%>
<%
Function FormToString()
Dim strOut
strKeys = objFM.Keys
strValues = objFM.Items
For intCnt = 0 To objFM.Count -1
strOut = strOut & strKeys(intCnt) & "=" & strValues(intCnt) & Chr(10)
Next
FormToString = strOut
End Function
%>
<%
Function ReportError(strMess)
If Len(strMess) < 1 Then
strMess = strError
End If
strErr = "The following error(s) happened: <br>" & strMess
Response.Clear
%>
<!--*******ERRONEOUS SUBMISSION RESPONSE - START*******-->
<!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
<h1>Error!</h1>
<!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->
<%'Error messages will be output here, between your html%>
<%
Response.Write(strErr)
%>
<!--ADD YOUR OWN HTML BOTTOM SECTION STARTING HERE-->
<p>
<b>Click on you browser's <i>Back</i> button to correct any mistakes in your input</b>
</p>
<!--ADD YOUR OWN HTML BOTTOM SECTION UP TO HERE-->
<!--******ERRONEOUS SUBMISSION RESPONSE - END*******-->
<%
Credit
Response.End
End Function
%>
<%Function Credit%>
<!--START OF CREDIT - DO NOT CHANGE OR REMOVE ANYTHING BELOW THIS LINE-->
<p align=center>
<font face="Arial,Helvetica" size=1>
Mailer software is freeware by
<a href="[URL unfurl="true"]http://www.cgiware.com/"[/URL] target="_top">CGIware</a>
<a href="[URL unfurl="true"]http://www.cgiware.com/"[/URL] target="_top"><img src="[URL unfurl="true"]http://www.cgiware.com/powered.gif"[/URL] align="absmiddle" border="0"></a>
</font>
</p>
<!--END OF CREDIT-->
<%End Function%>