title: How can I set the var subject in google forms script editor to return the values of specified fields in the form/sheet its is connected to?
body: <p>How can I set the var subject in google forms script editor to return the values of specified fields in the form/sheet its is connected to? </p>
  
  <p>For example, if my column headers and corresponding form fields were, "Name" and "Date" respectively, how would I code the "var subject =" to pull that info from those columns, so that the subject of the confirmation email includes that data?</p>
  
  <p>The code below pulls my Form Data from Google Docs into an Email confirmation Message, and displays the data entered. I want to customize the script to have custom email subject lines that match one or more of the form fields, instead of just a set "phrase" (i.e. "New Order Form") like it is now.</p>
  
  <pre><code>function sendFormByEmail(e) 
  {    
  
    var email = "my email"; 
  
    var subject = "New Order Form";
  
    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>