Forms sending some blank emails

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lstanikmas@softscape.com

    #1

    Forms sending some blank emails

    Hi, I'm validating a form with this ASP but receiving some blank email
    responses; does anyone see anything wrong with it?:

    function isFormVarExclud ed(thisForm, strToCheck)
    {
    var strExcludeVars = thisForm.elemen ts["$excludeva rs"].value;
    var arrExcludeVars = strExcludeVars. split(",");
    for (var j=0; j<arrExcludeVar s.length; j++)
    {
    if (arrExcludeVars[j] == strToCheck) return true;
    }
    return false;
    }

    function getFormVars(thi sForm)
    {
    var oFormVars = thisForm.elemen ts["$formvars"];
    var strPrevVal = "";
    oFormVars.value = "";
    for (var x=0,objElem=nul l; objElem=thisFor m.elements.item (x); x++)
    {
    if (!isFormVarExcl uded(thisForm, objElem.name))
    {
    if (objElem.name != strPrevVal)
    oFormVars.value += objElem.name + ",";
    }
    strPrevVal = objElem.name;
    }
    oFormVars.value = oFormVars.value .substr(0,oForm Vars.value.leng th-1);
    }
  • Bob Milutinovic

    #2
    Re: Forms sending some blank emails

    <lstanikmas@sof tscape.comwrote in message
    news:56fd3ebb-d778-40d0-b8d0-5609725f513f@h2 g2000hsg.google groups.com...
    Hi, I'm validating a form with this ASP but receiving some blank email
    responses; does anyone see anything wrong with it?:
    >
    function isFormVarExclud ed(thisForm, strToCheck)
    {
    var strExcludeVars = thisForm.elemen ts["$excludeva rs"].value;
    var arrExcludeVars = strExcludeVars. split(",");
    for (var j=0; j<arrExcludeVar s.length; j++)
    {
    if (arrExcludeVars[j] == strToCheck) return true;
    }
    return false;
    }
    >
    function getFormVars(thi sForm)
    {
    var oFormVars = thisForm.elemen ts["$formvars"];
    var strPrevVal = "";
    oFormVars.value = "";
    for (var x=0,objElem=nul l; objElem=thisFor m.elements.item (x); x++)
    {
    if (!isFormVarExcl uded(thisForm, objElem.name))
    {
    if (objElem.name != strPrevVal)
    oFormVars.value += objElem.name + ",";
    }
    strPrevVal = objElem.name;
    }
    oFormVars.value = oFormVars.value .substr(0,oForm Vars.value.leng th-1);
    }
    I may as well ask the obvious; is this script on the server or the client?

    There isn't anything in your supplied code relating directly to the sending
    of e-mails (nor for that matter relating explicitly to server-side code).

    How are you sending them? Have you tested for existence of content in the
    relevant string(s) immediately prior to sending?

    - Bob.


    Comment

    • lstanikmas@softscape.com

      #3
      Re: Forms sending some blank emails

      On Sep 29, 8:20 pm, "Bob Milutinovic" <cogni...@gmail .comwrote:
      <lstanik...@sof tscape.comwrote in message
      >
      news:56fd3ebb-d778-40d0-b8d0-5609725f513f@h2 g2000hsg.google groups.com...
      >
      >
      >
      >
      >
      Hi, I'm validating a form with this ASP but receiving some blank email
      responses; does anyone  see anything wrong with it?:
      >
      function isFormVarExclud ed(thisForm, strToCheck)
      {
      var strExcludeVars = thisForm.elemen ts["$excludeva rs"].value;
      var arrExcludeVars = strExcludeVars. split(",");
      for (var j=0; j<arrExcludeVar s.length; j++)
      {
      if (arrExcludeVars[j] == strToCheck) return true;
      }
      return false;
      }
      >
      function getFormVars(thi sForm)
      {
      var oFormVars = thisForm.elemen ts["$formvars"];
      var strPrevVal = "";
      oFormVars.value = "";
      for (var x=0,objElem=nul l; objElem=thisFor m.elements.item (x); x++)
      {
      if (!isFormVarExcl uded(thisForm, objElem.name))
      {
      if (objElem.name != strPrevVal)
      oFormVars.value += objElem.name   + ",";
      }
      strPrevVal = objElem.name;
      }
      oFormVars.value = oFormVars.value .substr(0,oForm Vars.value.leng th-1);
      }
      >
      I may as well ask the obvious; is this script on the server or the client?
      >
      There isn't anything in your supplied code relating directly to the sending
      of e-mails (nor for that matter relating explicitly to server-side code).
      >
      How are you sending them? Have you tested for existence of content in the
      relevant string(s) immediately prior to sending?
      >
      - Bob.- Hide quoted text -
      >
      - Show quoted text -
      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="javas cript" type="text/javascript">
      <!--
      function MM_validateForm () { //v4.0
      if (document.getEl ementById){
      var
      i,p,q,nm,test,n um,min,max,erro rs='',args=MM_v alidateForm.arg uments;
      for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
      val=document.ge tElementById(ar gs[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.substr ing(8,p); max=test.substr ing(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'+er rors);
      document.MM_ret urnValue = (errors == '');
      } }
      //-->
      </script>

      Then there's this in the form tag:

      <form action="../../scripts/handleInfoReque st.asp" method="post"
      name="info_requ est"
      onSubmit="getFo rmVars(document .info_request); MM_validateForm ('name','','R', 'phone','','R', 'email','','Ris Email','state', '','R');return
      document.MM_ret urnValue">

      which refers to this on the server:

      <%@LANGUAGE = "JScript"%>
      <%

      function showError(descr iption)
      {
      %>
      <html>
      <body>
      <p>
      ERROR: <%=description% >
      </p>
      </body>
      </html>
      <%
      }

      function showHelp()
      {
      %>
      <html>
      <body>
      Available Parameters: toemail, fromemail, subject, content,
      redirectto
      </body>
      </html>
      <%
      }

      function getFormDataAsMs g(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.l ength; i++)
      {
      itemVal = new String(Request. Form(arrFormVar s[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 getFormDataAsCS V()

      {
      var strCSVLine = "";
      var arrFormVars = new String(Request. Form("$formvars ")).split(" ,");
      for (i=0; i<arrFormVars.l ength; i++)
      {
      var itemVal = new String(Request. Form(arrFormVar s[i]));
      if (itemVal != "undefined" )
      {
      var re1 = /\"/g;
      var re2 = /\r\n/g;
      var re3 = /\n/g;
      strCSVLine += "\"" + itemVal.replace (re1, "'").replace(re 2, "
      ").replace( re3, " ") + "\"";
      }
      else
      strCSVLine += "\"\"";
      if (i<arrFormVars. length-1) strCSVLine += ",";
      }
      return strCSVLine;
      }


      function appendToFile(st rFileName, strContent)
      {
      if (strFileName == '' || strFileName == undefined) strFileName =
      "default.tx t";
      strFileName = "d:/Web/WebDB/" + strFileName;

      fs = new ActiveXObject(" Scripting.FileS ystemObject");

      var bIsNewFile = false;
      if (fs.FileExists( strFileName))
      f = fs.GetFile(strF ileName);
      else
      {
      bIsNewFile = true;
      fs.CreateTextFi le(strFileName) ;
      f = fs.GetFile(strF ileName);
      }

      ts = f.OpenAsTextStr eam("8", "-2");
      if (bIsNewFile)
      {
      ts.WriteLine(ne w String(Request. Form("$formvars ")));
      }
      ts.WriteLine(st rContent);
      ts.Close( );
      }

      function sendMail(fromem ail, 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.Configurati on.Fields("http ://schemas.microso ft.com/cdo/
      configuration/smtpserver") = "10.0.4.9";
      msg.Configurati on.Fields("http ://schemas.microso ft.com/cdo/
      configuration/sendusing") = 2;
      msg.Configurati on.Fields.Updat e();
      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("$redirect to"));
      var strFileName = new String(Request. Form("$saveas") );

      appendToFile(st rFileName, getFormDataAsCS V());
      if (sendMail("info .request@www.so ftscape.com", strToEmail, strSubject,
      getFormDataAsMs g(false)))
      Response.Redire ct(strRedirectU RL);
      %>

      Someone said it's a SPAM problem, but IT says there's no indication of
      a SPAM problem in the headers of the blank emails.

      Thanks much

      Comment

      Working...