您好,我是Google Apps脚本的新手。我有一个包含6列和1行的Google表格,一旦我可以运行就会插入更多
我的目标是从我的第1列的电子邮件列表中发送自动电子邮件。并使用第2-6列的电子邮件中的文本,我设法发送电子邮件,但它混淆了它全部一起。
是否有人知道要编写什么代码才能拥有正常的电子邮件,并为每列添加下一行,并在列之前添加“你的学生”之类的文字?
这就是我所拥有的
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 1; // Number of rows to process
// Fetch the range of cells A1:F2
var dataRange = sheet.getRange(startRow, 1, numRows, 5)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var message = "Hello your Student" + row[1]
**" Has done a marvelous job in Class" + row[2]
" His new area to grow involves" + row[3]+ row [4]+ row [5] ;**
var subject = "Report for your Student";
MailApp.sendEmail(emailAddress, subject, message);
} }
在电子邮件中没有看到加星标的内容,也许是因为它出现在下一行,我不知道要编写什么代码来引入它仍然是为了保持它并继续使用电子邮件中的空格。感谢
答案 0 :(得分:0)
class Foo extends Base {
static build(): Foo {
const instance = Base.build(this); // `instance` will be typed as `Foo` instead of `Base`
// do something specific with instance
return instance;
}
}
或者如果您需要换行
var message = "Hello your Student" + row[1]
+ " Has done a marvelous job in Class" + row[2]
+ " His new area to grow involves" + row[3]+ row [4]+ row [5] ;
答案 1 :(得分:0)
使用html可以添加中断和/或其他格式,例如粗体。
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 1; // Number of rows to process
// Fetch the range of cells A1:F2
var dataRange = sheet.getRange(startRow, 1, numRows, 5)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var myMessage = "<b>Hello your Student</b> " + row[1] + " <br> Has done a marvelous job in Class" + row[2] + "<br> His new area to grow involves:" + "<br>" + row[3] + "<br>" + row [4] + "<br>" + row [5] ;
var subject = "Report for your Student";
MailApp.sendEmail(emailAddress, subject, 'text Body',{htmlBody: myMessage});
}}
&#13;