我通过Google Apps脚本发送包含数据范围的电子邮件,在发送电子邮件时,数据以一种格式返回,其中单元格内容之间用逗号分隔之一。
我希望以表格格式或至少在不同的行上发送它们(根据范围,只有1列,最多5行) - 有人可以帮忙吗?
function sendemail () {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = SpreadsheetApp.getActiveSheet();
var targetSheet = ss.getSheetByName("Responses");
var vCodes = ss.getSheetByName("Codes")
var vResults = targetSheet.getRange("D2").getValue();
var emailAddresses = targetSheet.getRange("B2").getValue()
var dataRangeDay = vCodes.getRange(1, 1, vResults, 1).getValues();
var dataRangeWeek = vCodes.getRange(1, 2, vResults, 1).getValues();
var dataRangeMonth = vCodes.getRange(1, 3, vResults, 1).getValues();
var subject = "Here are your Wi-Fi Codes!";
var vLength = targetSheet.getRange("C2").getValue();
var vCompareday = "24 hours";
var vCompareweek = "7 days";
var vComparemonth = "28 days";
if (vLength.equals(vCompareday)) {
MailApp.sendEmail(emailAddresses, subject, dataRangeDay);
}
else
if (vLength.equals(vCompareweek)) {
MailApp.sendEmail(emailAddresses, subject, dataRangeWeek);
}
else
if (vLength.equals(vComparemonth)) {
MailApp.sendEmail(emailAddresses, subject, dataRangeMonth);
}
targetSheet.deleteRows(2);
vCodes.deleteRows(1,vResults);
}
答案 0 :(得分:0)
以html格式发送。有关高级选项的官方api文档可以很好地解释样本。