Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I'm trying to write a script to send emails from a google spreadsheet. My specifications are:

  1. Send email upon form submit
  2. Only send to email address listed on form

I have written a sendEmail function. However, it is sending it to ALL the email addresses in the specified column of the spreadsheet. How can I modify it to only send the email to a specific email address at the time the form is submitted?

Here is what I have so far:

function sendEmails() {
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses");
    var dataRange = sheet.getDataRange();
    // Fetch values for each row in the Range.
    var data = dataRange.getValues();
    for (var i=1;i<data.length;i++) {
        // For loop starts from i=1 because we have to start from second row
        var emailAddress = data[i][12];  // email address in column N
        var message = "Your Coordinator " + data[i][5] + " has submitted a QA Dispute for your review."     // body of email message 
        var subject = "QA Dispute for Call ID: " + data[i][7];       // call ID in column H
        MailApp.sendEmail(emailAddress, subject, message);
share|improve this question
Are you triggering this from the form or the spreadsheet? –  Tom Horwood Oct 11 '13 at 15:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.