By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,230 Members | 2,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,230 IT Pros & Developers. It's quick & easy.

HTML form generating semi- blank emails

P: n/a
Hi, My HTML form is generating some blank email
responses; does anyone see anything wrong with the scripts?:

function isFormVarExcluded(thisForm, strToCheck)
{
var strExcludeVars = thisForm.elements["$excludevars"].value;
var arrExcludeVars = strExcludeVars.split(",");
for (var j=0; j<arrExcludeVars.length; j++)
{
if (arrExcludeVars[j] == strToCheck) return true;
}
return false;
}
function getFormVars(thisForm)
{
var oFormVars = thisForm.elements["$formvars"];
var strPrevVal = "";
oFormVars.value = "";
for (var x=0,objElem=null; objElem=thisForm.elements.item(x);x
++)
{
if (!isFormVarExcluded(thisForm, objElem.name))
{
if (objElem.name != strPrevVal)
oFormVars.value += objElem.name +
",";
}
strPrevVal = objElem.name;
}
oFormVars.value =
oFormVars.value.substr(0,oFormVars.value.length-1);

This is on the server. I didn't create it but it looks like a
validator script. The emails I receive (form responses) sometimes
have
only []: in the body but some come in filled out properly (contact
info, product interest, etc.). There's also a validator in the HTML
form page:
<script language="javascript" type="text/javascript">
<!--
function MM_validateForm() { //v4.0
if (document.getElementById){
var
i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=document.getElementById(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') { num = parseFloat(val);
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 (num<min || max<num) 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>
Then there's this in the form tag:
<form action="../../scripts/handleInfoRequest.asp" method="post"
name="info_request"
onSubmit="getFormVars(document.info_request);MM_va lidateForm('name','','R','phone','','R','email',' ','RisEmail','state','','R');return
document.MM_returnValue">
which refers to this on the server:
<%@LANGUAGE = "JScript"%>
<%
function showError(description)
{
%>
<html>
<body>
<p>
ERROR: <%=description%>
</p>
</body>
</html>
<%
}
function showHelp()
{
%>
<html>
<body>
Available Parameters: toemail,
fromemail, subject, content,
redirectto
</body>
</html>
<%
}
function getFormDataAsMsg(bUseHTML)
{
var dt = new Date();
var crlf = "\r\n";
if (bUseHTML) crlf = "<br>"
var strMailMsg = (dt.getMonth()+1) + "/" + dt.getDate() + "/"
+
dt.getFullYear() +crlf;
var arrFormVars = new
String(Request.Form("$formvars")).split(",");
for (i=0; i<arrFormVars.length; i++)
{
itemVal = new String(Request.Form(arrFormVars[i]));
if (bUseHTML)
{
if (itemVal != "undefined")
strMailMsg += "<b>[" + arrFormVars[i]
+ "]</b>:&nbsp;" + itemVal +
crlf;
else
strMailMsg += "<b>[" + arrFormVars[i]
+ "]</b>:&nbsp;" + crlf;
}
else
{
if (itemVal != "undefined")
strMailMsg += "[" + arrFormVars[i] +
"]: " + itemVal + crlf;
else
strMailMsg += "[" + arrFormVars[i] +
"]: " + crlf;
}
}
return strMailMsg;
}
function getFormDataAsCSV()
{
var strCSVLine = "";
var arrFormVars = new
String(Request.Form("$formvars")).split(",");
for (i=0; i<arrFormVars.length; i++)
{
var itemVal = new
String(Request.Form(arrFormVars[i]));
if (itemVal != "undefined")
{
var re1 = /\"/g;
var re2 = /\r\n/g;
var re3 = /\n/g;
strCSVLine += "\"" +
itemVal.replace(re1, "'").replace(re2, "
").replace(re3, " ") + "\"";
}
else
strCSVLine += "\"\"";
if (i<arrFormVars.length-1) strCSVLine
+= ",";
}
return strCSVLine;
}
function appendToFile(strFileName, strContent)
{
if (strFileName == '' || strFileName == undefined) strFileName
=
"default.txt";
strFileName = "d:/Web/WebDB/" + strFileName;
fs = new ActiveXObject("Scripting.FileSystemObject");
var bIsNewFile = false;
if (fs.FileExists(strFileName))
f = fs.GetFile(strFileName);
else
{
bIsNewFile = true;
fs.CreateTextFile(strFileName);
f = fs.GetFile(strFileName);
}
ts = f.OpenAsTextStream("8", "-2");
if (bIsNewFile)
{
ts.WriteLine(new String(Request.Form("$formvars")));
}
ts.WriteLine(strContent);
ts.Close( );
}
function sendMail(fromemail, toemail, subject, content)
{
var msg = new ActiveXObject("CDO.Message");
msg.From = fromemail;
msg.To = toemail;
msg.Subject = subject;
msg.TextBody = content;
Response.Write("*" + toemail);
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/
configuration/smtpserver") = "10.0.4.9";
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/
configuration/sendusing") = 2;
msg.Configuration.Fields.Update();
try
{
msg.Send();
}
catch(e)
{
showError("CDO.Message.Send() failed: " +
e.description);
return false;
}
return true;
}
var strSubject = new String(Request.Form("$subject"));
var strToEmail = new String(Request.Form("$toemail"));
var strRedirectURL = new String(Request.Form("$redirectto"));
var strFileName = new String(Request.Form("$saveas"));
appendToFile(strFileName, getFormDataAsCSV());
if (sendMail("info.requ...@www.softscape.com", strToEmail,
strSubject,
getFormDataAsMsg(false)))
Response.Redirect(strRedirectURL);
%>
Someone said it's a SPAM problem, but someone else says there's no
indication of
a SPAM problem in the headers of the blank emails.
Thanks much

Nov 11 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Lelu wrote:
Hi, My HTML form is generating some blank email
responses; does anyone see anything wrong with the scripts?:
This is c.i.w.a.html. If you don't know what HTML is, it's time to learn.

Please feel free to return when you have a question about HTML authoring for
the WWW. By that time, you have hopefully learned the importance of posting
a URL.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Nov 11 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.