0

So im using the following code for sendFormByEmail and it works great for sending the required information by email. The only problem is its sending a blank email with all the fields left blank except for the timestamp at the same time. Ive checked for multiple triggers and have removed the trigger and added another one. same thing

the code is

{    
  var s = SpreadsheetApp.getActiveSheet();
  var headers = s.getRange(1,1,1,26).getValues()[0];    
  var email = "jlewis@xxxxxxx.ca"; 
  var subject = "Service Call";
    var message = "";
for(var i in headers) {
    if (e.namedValues[headers[i]]) {
      message += headers[i] + ' : '+ e.namedValues[headers[i]].toString() + "\n\n"; 

    }
  }
   MailApp.sendEmail(email, subject, message); 

}

player0
  • 124,011
  • 12
  • 67
  • 124
Zeekane
  • 53
  • 5
  • How is this function triggered? And how does it get the `e` parameter? Knowing that may help fix the bug. – ADW Nov 10 '19 at 05:22
  • 1
    Take a look at this answer: https://stackoverflow.com/a/58782686/7215091 – Cooper Nov 10 '19 at 05:24
  • Possible duplicate of [Sending emails twice with MailApp.sendEmail](https://stackoverflow.com/questions/58781729/sending-emails-twice-with-mailapp-sendemail) – carlesgg97 Nov 11 '19 at 10:19

0 Answers0