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