frainbreeze
Technical User
hello,
i am new to asp so please bear with me! this is the script we are using for any comments/enquiries to be sent as an email to us via our website. even if there are no changes to the actual code, whether or not an email is actually sent seems to be completely random..i.e. it'll work one minute and the next it won't. can anyone please figure out where things are going wrong? i don't understand why it is being so temperamental..
this is in the head:
this is in the body:
thanks for any help in advance!
annie
i am new to asp so please bear with me! this is the script we are using for any comments/enquiries to be sent as an email to us via our website. even if there are no changes to the actual code, whether or not an email is actually sent seems to be completely random..i.e. it'll work one minute and the next it won't. can anyone please figure out where things are going wrong? i don't understand why it is being so temperamental..
this is in the head:
Code:
<script language="JavaScript">
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') {
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
</script>
this is in the body:
Code:
<%
Dim objCDO ' Our CDO object
Dim strTo ' Strings to hold our email fields from the form
Dim strSubject
Dim strBody
Dim strnum
Dim reciever_email
strTo = "my@emailaddress.com"
str_fullName = Request.form("name")
str_CompanyName = Request.form("company")
str_EmailAddress = Request.form("emailFrom")
str_message = Request.form("emailMessage")
strSubject = "Message from the website"
strBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & vbCrLf _
& "<html>" & vbCrLf _
& "<head>" & vbCrLf _
& " <title>Message from Livegroup website</title>" & vbCrLf _
& " <meta http-equiv=Content-Type content=""text/html; charset=iso-8859-1"">" & vbCrLf _
& "</head>" & vbCrLf _
& "<body bgcolor='#FFFFFF' style='font-family: ariel, sans-serif'>" & vbCrLf _
& " <h2>Message from Livegroup website</h2>" & vbCrLf _
& " <p>" & vbCrLf _
& " </p>" & vbCrLf _
& " <font size='3'>" & vbCrLf _
& " <p>Name: " & str_fullName & "</p>" & vbCrLf _
& " <p>Company: " & str_CompanyName & "</p>" & vbCrLf _
& " <p>Message: " & str_message & "</p>" & vbCrLf _
& " </font>" & vbCrLf _
& "</body>" & vbCrLf _
& "</html>" & vbCrLf
If ( NOT Request.form( "Submit" )= "Send" ) THEN
%>
<table>
<tr>
<td height="130" valign="bottom"><font size="2">Please feel free to contact us using the form below: <br></font></td>
</tr>
<tr>
<form action="contact.asp" name="form1" method="POST">
<table>
<tr>
<td><font style="font-weight: bold">Name</font>
</td>
<td><input name="name" type="text" maxlength="50" style="width: 150px">
</td>
</tr>
<tr>
<td><font style="font-weight: bold">Company</font>
</td>
<td><input name="company" type="text" maxlength="150" style="width: 150px">
</td>
</tr>
<tr>
<td><font style="font-weight: bold">Email</font>
</td>
<td><input name="emailFrom" type="text" maxlength="50" style="width: 150px">
</td>
</tr>
<tr>
<td><font style="font-weight: bold">Enquiry</font>
</td>
<td><textarea name="emailMessage" rows="5" wrap="virtual" noScrollBar style="width: 200px"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input class="button" name="submit" type="submit" value="Send" onClick="MM_validateForm('name','','R','emailFrom','','RisEmail');return document.MM_returnValue">
</td>
</tr>
</table>
</form>
</tr>
</table>
</body>
</html>
<%
Else
' Send our message:
' Note that I'm using the Win2000 CDO and not CDONTS!
Set objCDO = Server.CreateObject("CDO.Message")
With objCDO
.To = strTo
.Cc = strCc
.From = str_EmailAddress
.Subject = strSubject
.HtmlBody = strBody
.Send
End With
Set objCDO = Nothing
%>
<table width="60%" align="center">
<tr align="center">
<td class="head" align="center">Email sent, Thank you
</td>
</tr>
</table>
</body>
</html>
<%
end if
%>
thanks for any help in advance!
annie