Here's a google app script that sends a custom email to those submitting a Google Form (emails collected in column E):
function sendFormEmails(e) {
var emailAddress = e.values[4];
var subject = "subject";
var message = "message";
var fromAddress = "fromemail@emaildomain.com";
var ccAddress = "ccemail@emaildomain.com";
MailApp.sendEmail(emailAddress, subject, message, {htmlBody: message, from: fromAddress, cc: ccAddress});
}
A On Form Submit trigger is set up on this function. When someone submits the google form for the first time, it works fine (aside from sending the email from the specified fromAddress; it only sends from the Google account associated with the script). When the respondent edits their form, however, this function also executes. In this case, an email is sent from the Google account associated with the script and cc'd to (ccemail@emaildomain.com). It isn't sent to the respondent unless they change their email on the edit form. I don't want this function to fire at all when a response is edited. Is there a simple conditional logic to write into this app script so that it only fires when a new response is submitted? Also, is there any way to have the email sent from the specified fromAddress opposed to the google account associated with the script?
I tried the onFormSubmit function, but this still sends when a Form is edited.