Guest User

Untitled

a guest
Apr 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. function sendMail(){
  2. var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  3. var data = sh.getRange("A2:O38").getValues();
  4. //var htmltable =[];
  5.  
  6. var TABLEFORMAT = 'cellspacing="2" cellpadding="2" dir="ltr" border="1"style="width:100%;table-layout:fixed;font-size:10pt;font-family:arial,sans,sans-serif;border-collapse:collapse;border:1px solid #ccc;font-weight:normal;color:black;background-color:white;text- align:center;text-decoration:none;font-style:normal;'
  7. var htmltable = '<table ' + TABLEFORMAT +' ">';
  8.  
  9. for (row = 0; row<data.length; row++){
  10.  
  11. htmltable += '<tr>';
  12.  
  13. for (col = 0 ;col<data[row].length; col++){
  14. if (data[row][col] === "" || 0) {htmltable += '<td>' + 'None' + '</td>';}
  15. else
  16. if (row === 0) {htmltable += '<th>' + data[row][col] + '</th>';
  17. }
  18.  
  19. else {htmltable += '<td>' + data[row][col] + '</td>';}
  20. }
  21.  
  22. htmltable += '</tr>';
  23. }
  24.  
  25. htmltable += '</table>';
  26. Logger.log(data);
  27. Logger.log(htmltable);
  28. MailApp.sendEmail(Session.getActiveUser().getEmail(), 'Daily report','' ,{htmlBody: htmltable})
Add Comment
Please, Sign In to add comment