Is there a way to make the output of 'message' in the email neater? Right now, it's just 1 line of long data sent to the user. I tried using <br>
but it didnt seem to work.
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getDataRange();
var data = range.getValues();
setUpCalendar_(data, range);
var message = "";
for (i in data) {
var row = data[i];
var subject = "Compiled List for " + row[0];
message += row[0] + row[1] + row[2] + row[3];
}
MailApp.sendEmail("emailgoeshere", subject, message);
}
尝试使用\\ n开始新行
As mentioned in the comment above, this has already been explained a few times...
below is an example that sends data in text format AND in html format so that recipients that reject html content will still see something 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>'
for (i in data) {
var row = data[i];
var subject = "Compiled List for " + 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 the background color to your taste
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.