简体   繁体   中英

Script to Send an Email with Google Form Responses?

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?

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:

电流触发

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('mike@example.com', 'Attachment example', 'Please see the attached file.', {
     attachments: [file.getAs(MimeType.PDF)],
     name: 'Automatic Emailer Script'
 });
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM