有没有办法让电子邮件更整洁地输出'message'?
现在,它只发送给用户的1行长数据。我尝试使用<br>
,但它似乎没有用。
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);
}
答案 0 :(得分:0)
尝试使用\ n开始新行
答案 1 :(得分:0)
正如上面的评论所述,这已经解释了几次......
下面是一个以文本格式和html格式发送数据的示例,这样拒绝html内容的收件人仍会看到可读的内容; - )
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});
}
根据您的喜好更改背景颜色