John Fullmer
John Fullmer

Reputation: 1

Google forms auto-email not showing up

My company has a google form that we use to submit requests for data pulls. I created a script that auto emails form responses to myself, as well as a copy to the submitter. The script is:

function Initialize() {

  var triggers = ScriptApp.getScriptTriggers();

  for(var i in triggers) {
    ScriptApp.deleteTrigger(triggers[i]);
  }

  ScriptApp.newTrigger("SendGoogleForm")
  .forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet())
  .onFormSubmit()
  .create();

}

function SendGoogleForm(e) 
{  
  try 
  {      
    // You may replace this with another email address
    var email = "My Email Goes here"

    var Owner = e.namedValues["Owner:"].toString();
    cc = email + "," + Owner


    Adv = e.namedValues["Advertiser Name:"].toString();
    IO = e.namedValues["IO Name:"].toString();
    Tog = "Pixel Request " + Adv + " " + IO;

    // Optional but change the following variable
    // to have a custom subject for Google Form email notifications
    var subject = Tog;  

    var s = SpreadsheetApp.getActiveSheet();
    var columns = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];    
    var message = ""; 

    // Only include form fields that are not blank
    for ( var keys in columns ) {
      var key = columns[keys];
      if ( e.namedValues[key] && (e.namedValues[key] != "") ) {
        message += key + ' :: '+ e.namedValues[key] + "\n\n"; 
      }
    }

    // This is the MailApp service of Google Apps Script
    // that sends the email. You can also use GmailApp for HTML Mail.

    MailApp.sendEmail(cc, subject, message);


  } catch (e) {
    Logger.log(e.toString());
  }

}

The script sends the emails without a problem. However, while the email sent to myself shows up in my sent mail, no copy is delivered to my inbox and it is marked as read; this is a problem because then I do not know that requests have been submitted which was the point of this creation. This seems anomalous as normally emails to yourself will typically show up in the inbox as unread. Does anyone know a way I might be able to fix this?

Upvotes: 0

Views: 188

Answers (1)

Amit Agarwal
Amit Agarwal

Reputation: 11268

This is not an issue with the Google Script. This is probably how Gmail handles email where the sender and recipient is you.

Upvotes: 1

Related Questions