SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var subject = form.subject;  // Title of Email with class name
  2.      
  3. var subject = index.html().getEmailSubject();
  4.      
  5. // Send Email Script for Edit Email Section Popup HTML (using check boxes, etc.)
  6.  
  7.  function sendEmail() {
  8.  
  9.    var ui = SpreadsheetApp.getUi(); // Same variations.
  10.    var result = ui.alert(
  11.      'Send Emails',
  12.      'Are you sure you want to send missing assignment emails?',
  13.       ui.ButtonSet.YES_NO);
  14.  
  15.    // Process the user's response.
  16.   if (result == ui.Button.YES) {
  17.     // User clicked "Yes".
  18.     var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Missing Student Information");
  19.     Logger.log("test 1");
  20.     var email_sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Template");
  21.     Logger.log("test 2");
  22.     var email_data = email_sheet.getDataRange().getValues();
  23.     Logger.log("test 3");
  24.  
  25.   var startRow = 2;  // First row of data to process
  26.   var numRows = sheet.getDataRange().getNumRows();   // Number of rows to process
  27.     Logger.log(numRows);
  28.    // Fetch the range of cells A2:(numRows)3
  29.   var dataRange = sheet.getRange(startRow, 1, numRows, 6);
  30.  
  31.   // Fetch values for each row in the Range.
  32.   var data = dataRange.getValues();
  33.   for (var i = 0; i < numRows;i++) {
  34.     var row = data[i];
  35.     var student_name = row[0];     // Gets student name
  36.     var class = row[1];            // Gets class name
  37.     var student_email = row[2];    // Gets student email address
  38.     var parent_email = row[3];     // Gets parent email address
  39.     var missing = row[4];          // Gets number of missing assignments
  40.     var assign_list = row[5];
  41.  
  42.     Logger.log("Before get email subject header.");
  43.  
  44.     var subject = index.html().getEmailSubject();  // Title of Email with class name
  45.     Logger.log("starting "+student_name+" "+missing+assign_list);
  46.  
  47.     Logger.log("After get email subject header.");
  48.      
  49. <!DOCTYPE html>
  50. <html>
  51.   <head>
  52.     <base target="_top">
  53.     <script>
  54.       // Prevent forms from submitting.
  55.       function preventFormSubmit() {
  56.         var forms = document.querySelectorAll('form');
  57.         for (var i = 0; i < forms.length; i++) {
  58.           forms[i].addEventListener('submit', function(event) {
  59.             event.preventDefault();
  60.           });
  61.         }
  62.       }
  63.       window.addEventListener('load', preventFormSubmit);
  64.  
  65.       function handleFormSubmit(formObject) {
  66.         google.script.run.withSuccessHandler(updateUrl).SendEmails(formObject);
  67.         google.script.host.close();
  68.       }
  69.       function updateUrl(url) {
  70.         var div = document.getElementById('output');
  71.         div.innerHTML = '<a href="' + url + '">Got it!</a>';
  72.       }
  73.       function setDefaultSubject(subject) {
  74.         if (subject != null && subject != "") {
  75.           var form = document.getElementById('myForm');
  76.           form.Subject.value = subject;
  77.         }
  78.       }
  79.       function setDefaultBody(body) {
  80.         if (body != null && body != "") {
  81.           var form = document.getElementById('myForm');
  82.           form.Body.value = body;
  83.         }
  84.       }
  85.       google.script.run
  86.         .withSuccessHandler(setDefaultBody)
  87.         .getEmailBody();
  88.       google.script.run
  89.         .withSuccessHandler(setDefaultSubject)
  90.         .getEmailSubject();
  91.     </script>
  92.   </head>
  93.   <body>
  94.   <input type="checkbox" name="send_Students" checked="checked" /> Email Students <input type="checkbox" name="send_Parents" checked="checked" /> Email Parents <br/><br/>
  95.     <form id="myForm" onsubmit="handleFormSubmit(this)">
  96.       Email Subject: <input style="width:500px" name="Subject" type="text" value="Current Missing Assignments List"/>
  97.       <br/name="Subject" type="text" value="Current Missing Assignments List"/>
  98.       <br/>
  99.       Email Body: <br/>
  100.       <textarea name="Body" style="width:750px; height:400px">
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