daily pastebin goal
38%
SHARE
TWEET

Untitled

a guest Jul 17th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sendEmails()
  2. {
  3.   var sheet = SpreadsheetApp.getActiveSheet();
  4.   var activeRange = sheet.getActiveRange();
  5.   var rows = sheet.getLastRow();
  6.   var dataRange = sheet.getRange(1, 1, rows, 2);
  7.   var data = activeRange.getValues();  
  8.   for (var i = 0; i < data.length; ++i)
  9.   {
  10.     var row = data[i];
  11.     var name = row[1];
  12.     var email = row[2];
  13.     var subject = "Тема письма";
  14.     var body = "Тест, " + name + "! проверка рассылки";      
  15.     MailApp.sendEmail(email, subject, body);
  16.     sheet.getRange(i+1, 6).setValue("Отправлено");
  17.     SpreadsheetApp.flush(); <span id="pastemarkerend"> </span>
  18.   }
  19. }
  20.    
  21. sheet.getRange(i+1, 6).setValue("Отправлено");
RAW Paste Data
Top