SHARE
TWEET

Untitled

a guest Jul 21st, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Standalone script to create Form
  2. function createForm() {
  3.   const form = FormApp.create("Brochure request");
  4.   form.setTitle('Brochure request');
  5.   form.setCollectEmail(true);
  6. }
  7.  
  8. //Stored in Google Form - i.e. bound to form
  9. //Send brochure PDF when form filled out
  10. function example101() {
  11.   //Get email
  12.   const form = FormApp.getActiveForm();
  13.   const responses = form.getResponses();
  14.   const latestResponse = responses[responses.length-1];
  15.   const emailAddress = latestResponse.getRespondentEmail();
  16.  
  17.   //Get Slides and create PDF
  18.   const brochure = DriveApp.getFileById('ADD FILE ID HERE')
  19.                            .getAs(MimeType.PDF);
  20.  
  21.   //Send PDF in email
  22.   MailApp.sendEmail(emailAddress,
  23.                     'BROCHURE',
  24.                     'Please find attached this year\'s brochure.',
  25.                     {attachments: brochure,
  26.                      name: 'Brochure 2019'})
  27. }
  28.  
  29. function setUpTrigger() {
  30.   var form = FormApp.getActiveForm();
  31.   ScriptApp.newTrigger('example101')
  32.   .forForm(form)
  33.   .onFormSubmit()
  34.   .create();
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top