0

I've used a script in another spreadsheet that emails me whenever someone submits a form. It emails me with a few answers to important questions as well as a link to to view the full response on the spreadsheet.

Here is my original code that works:

function Outreach_FormMailer(e) {
    var recipient = "email@gmail.com";
    var timestamp = e.values[0];
    var name = e.values[1];
    var subject = e.values[1]+" completed a Report for "+e.values[3]
    var dates = e.values[7];
    var goalMet = e.values[9]
    var goalFocus = e.values[10]
    var hyperlink = "myawesomelink.com"
htmlBody = name+' just completed the O/R Report for these dates: '+dates+'<br><br>Form completed on: '+timestamp+'<br>Was the goal met? '+goalMet+'<br>What was the goal focus? '+goalFocus+                                                                            
    '<br><br>View the Form:<a href="'+hyperlink+'">Click Here</a>';

MailApp.sendEmail(recipient, subject, htmlBody, {htmlBody:htmlBody}); }

I wanted to use this code for a new form with different questions, so I edited the code to just correspond to the correct qeustions.

This is the code that doesn't work:

function Team_ApplicationMailer(e) {
    var recipient = "email@gmail.com";
    var timestamp = e.values[0];
    var name = e.values[3];
    var subject = e.values[1]+' filled out the Teams Application Form!' ;
    var startdate = e.values[12];
    var enddate = e.values[13]
    var Focus = e.values[19]
    var hyperlink="myawesomelink.com"
htmlBody = name+' from: '+e.values[1]+'just completed the Teams Application Form for these dates: '+startdate+' to '+enddate+'<br><br>Form completed on: '+timestamp+'<br><br>View the Form:<a href="'+hyperlink+'">Click Here</a>';
MailApp.sendEmail(recipient, subject, htmlBody, {htmlBody:htmlBody});

}

I've done several test emails and for some reason, this version of the script will not work. I am adding this script to a form that already has responses on the spreadsheet. Would that make a difference? Really not sure what I did wrong in transferring the code to a different spreadsheet.

  • 2
    Have you checked using the logger that the function is called and that values correspond to what they are supposed to? Do you get an error message or is just nothing happening? – Serge insas Feb 13 '13 at 10:16
  • When you configure the triggers for the script (Resources>Current Project's Triggers), to the right of the trigger is Notifications, which opens a dialog to set failure notifications. I always set that to notify me immediately. Often, when the Execution Transcript doesn't show anything, that email will have the information I'm looking for. – bigelowr Feb 15 '13 at 20:26

1 Answers1

0

Thanks for the comments guys. I actually realized the above code does work as is. I forgot that I setup a filter in Gmail that was sending the autoresponse email to a folder I didn't see instead of the inbox. No problem with the code, I just forgot to check the right place the email was sent to.