0
votes

I've set up a Google form and my responses are being recorded in a spreadsheet. Ideally I want the responses to also be sent via email.

I found this article, but it looks like this script only sends an email from a message field. I want to send the entire spreadsheet.

https://developers.google.com/apps-script/articles/sending_emails

Is there a way to do this?

1
you can refer to this page on how to send an email with attachments: developers.google.com/apps-script/reference/mail/mail-appKRR

1 Answers

0
votes

Send a spreadsheet when Google form is submitted.

  • Set up a form submit trigger from the spreadsheet or form.
  • Decide whether you want an attachment as a file or text in the email.
  • Get the data from the spreadsheet, or the entire file
  • Convert the data to text for the email, or a file for an attachment
  • Send the email

Create a trigger to run when form is submitted:

Current Triggers

Set Trigger:

Set Trigger

Write Code:

function respondToFormSubmit(e) {
  Logger.log('respondToFormSubmit ran');

  fncGetContentToSend();
  fncSendEmail();
}

function fncGetContentToSend() {
  Logger.log('fncGetContentToSend ran');

  var thisSS = SpreadsheetApp.openById('your ID');
  //Convert spreadsheet to PDF
}

function fncSendEmail() {
  Logger.log('fncSendEmail ran');

 // Send an email with a file from Google Drive attached as a PDF.
 var file = DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');
 GmailApp.sendEmail('[email protected]', 'Attachment example', 'Please see the attached file.', {
     attachments: [file.getAs(MimeType.PDF)],
     name: 'Automatic Emailer Script'
 });
};