javascript - Google Apps Script [Email Send] -
is there way make output of 'message' in email neater? right now, it's 1 line of long data sent user. tried using <br>
didnt seem work.
function sendemails() { var sheet = spreadsheetapp.getactivesheet(); var range = sheet.getdatarange(); var data = range.getvalues(); setupcalendar_(data, range); var message = ""; (i in data) { var row = data[i]; var subject = "compiled list " + row[0]; message += row[0] + row[1] + row[2] + row[3]; } mailapp.sendemail("emailgoeshere", subject, message); }
as mentioned in comment above, has been explained few times...
below example sends data in text format , in html format recipients reject html content still see readable ;-)
function sendemails() { var sheet = spreadsheetapp.getactivesheet(); var range = sheet.getdatarange(); var data = range.getvalues(); setupcalendar_(data, range); var txt = ""; var html = '<table style="background-color:lightblue;border-collapse:collapse;" border = 1 cellpadding = 5><tr>' (i in data) { var row = data[i]; var subject = "compiled list " + row[0]; txt += row[0] +' - '+ row[1] +' - '+ row[2] +' - '+ row[3]+'\n'; html+= '<td>'+row[0] +'</td><td>'+ row[1] +'</td><td>'+ row[2] +'</td><td>'+ row[3] +'</td></tr><tr>'; } html += '</tr></table>'; mailapp.sendemail('an email adress', subject, txt,{'htmlbody':html}); }
change background color taste
Comments
Post a Comment