title: setting up script to include google docs form data in email notification
body: <p>I've setup a form using googledocs. I just want to have the actual data entered into the form emailed to me, as opposed to the generic response advising that the form has been completed.</p>
  
  <p>I have no skill or experience with code etc, but was sure i could get this sorted. I've spent hours+hours and haven't had any luck.</p>
  
  <p>My form is really basic.it has 5 fields. 4 of which are just text responses, and one multiple choice. </p>
  
  <p>I found this tute online (http://www.labnol.org/internet/google-docs-email-form/20884/) which i think sums up what i'm trying to do, but have not been able to get it to work.</p>
  
  <p>from this site i entered the following code:</p>
  
  <pre><code>function sendFormByEmail(e) 
  {    
    var email = "reports.mckeir@gmail.com"; 
  
    var subject = "Google Docs Form Submitted";  
  
    var s = SpreadsheetApp.getActiveSheet();
    var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];    
    var message = "";    
  
   for(var i in headers)
  message += headers[i] + ' = '+ e.namedValues[headers[i]].toString() + "\n\n"; 
  
    MailApp.sendEmail(email, subject, message); 
  }
  </code></pre>
  
  <p>To this, i get the following response: -></p>
  
  <blockquote>
    <p>Your script, Contact Us Form Mailer, has recently failed to finish successfully. A summary of the failure(s) is shown below. To configure the triggers for this script, or change your setting for receiving future failure notifications, click here.</p>
  </blockquote>
  
  <p>The script is used by the document 100% Club.</p>
  
  <p>Details:</p>
  
  <pre><code>Start               Function        Error Message                                                       Trigger     End
  12/3/12 11:06 PM    sendFormByEmail TypeError: Cannot call method "toString" of undefined. (line 12)    formSubmit  12/3/12 11:06 PM
  </code></pre>
  
  <p>Is anyone able to help shed some light on this for me? I'm guessing i'm not including some data neeeded, but i honestly have no clue.</p>