I created a form using google docs spreadsheet, and created a script that sends an email when the user fills the form:
function sendFormByEmail(e){ var email = "AAA"; var subject = "XXX"; var message = ""; for(var field in e.namedValues) message += field + ' = '+ e.namedValues[field].toString() + "\n\n"; var advancedArgs = {replyTo:e.namedValues['E-mail'].toString()}; MailApp.sendEmail(email, subject, message, advancedArgs); }
the script works, but when it sends the email, data is not sorted as the fields of the form.
how can I modify my script to sort the values ​​as they are in the Spreadsheet (form)?