gpt4 book ai didi

javascript - Google 表格电子邮件脚本错误

转载 作者:行者123 更新时间:2023-12-02 13:47:18 26 4
gpt4 key购买 nike

我是创建脚本的新手,但我一直在尝试编写一个脚本来向 Google 表格中的 500 多封电子邮件发送消息。我复制了在 Google 教程上找到的代码,然后尝试将其调整到工作表中的相应列,并包含带有链接的格式化电子邮件。一切工作正常,直到我添加了自定义消息,现在我收到错误消息“参数列表后缺少 )。(第 28 行,文件“代码”)。”第 28 行是“MailApp.sendEmail(emailAddress, subject, message);”

我是新手,所以这可能是一个简单的错误。我在下面包含了完整的脚本。我感谢任何帮助。

var EMAIL_SENT = "EMAIL_SENT";

function sendEmails2() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2; // First row of data to process
var numRows = 523; // Number of rows to process
// Fetch the range of cells A2:F523
var dataRange = sheet.getRange(startRow, 1, numRows, 523)
// Fetch values for each row in the Range.
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var firstName = row[1];
var emailAddress = row[5]; // Sixth column
var message = <p>"Hi " + firstName + ",/n Are you looking for new ways to integrate technology into your lessons? Heartland AEA is offering a FREE professional development opportunity focused on integrating technology into Social Studies instruction. As part of our Technology Integration and Collaboration (TIC) series, this session will provide a free opportunity for educators from throughout Heartland's area to learn from exemplary teachers while collaborating with others who are passionate about education, technology, and social studies. We have a great lineup of presenters and would love to have as many educators as possible in attendance. If you are unable to attend in person, please consider participating through the livestream via Zoom.</p> +
<p>Whether you plan to attend in person or via Zoom, please '<a href=\"' + 'https://prodev.aeapdonline.org/4DCGI/TE099892111701INV&*' + '>register</a> in advance. More information about this and other upcoming TIC sessions can be found on the '<a href=\"' + 'https://sites.google.com/a/heartlandaea.org/heartland-tic/home' + '>TIC website</a>.</p> +
<p>Topic: 6-12 Social Studies: Quality Instruction Using Technology</p> +
<p>Date: January 12, 2017 </p> +
<p>Time: 8:30am - 11:30am </p> +
<p>Location: Johnston AEA</p> +
<p>To Register: '<a href=\"' + 'https://prodev.aeapdonline.org/4DCGI/TE099892111701INV&*' + '>Click Here</a>. It is FREE!</p> +
<p>Zoom Link: '<a href=\"' + 'https://heartlandaea.zoom.us/j/804914526' + '>https://heartlandaea.zoom.us/j/804914526</a> </p> +
<p>If you are unable to attend virtually or in person, we will post videos of each presentation to '<a href=\"' + 'https://www.youtube.com/playlist?list=PLRAy7hvczWAXWKj4b6buttfLsGWLKGP8s' + '>Heartland’s YouTube Channel</a> a few days after this session. </p> +
<p>Please pass this information on to all Social Studies teachers in your district or others in your building that might be interested in attending."</p>;

var emailSent = row[7]; // Seventh column
if (emailSent != EMAIL_SENT) { // Prevents sending duplicates
var subject = "Technology in Social Studies PD";
MailApp.sendEmail(emailAddress, subject, message);
sheet.getRange(startRow + i, 8).setValue(EMAIL_SENT);
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
}
}
}

最佳答案

有两件事可能会有所帮助。

由于您使用的是 html,因此使用它来发送电子邮件:

MailApp.sendEmail(emailAddress, subject, "", {htmlBody: message});

消息格式是否正确,有些地方似乎缺少“”。试试这个:

var message = "<p>Hi " + firstName + ",/n Are you looking for new ways to integrate technology into your lessons?"
+ "Heartland AEA is offering a FREE professional development opportunity focused on integrating technology into Social Studies instruction. As part of our Technology Integration and Collaboration (TIC) series, this session will provide a free opportunity for educators from throughout Heartland's area to learn from exemplary teachers while collaborating with others who are passionate about education, technology, and social studies. We have a great lineup of presenters and would love to have as many educators as possible in attendance. If you are unable to attend in person, please consider participating through the livestream via Zoom.</p>"
+ "<p>Whether you plan to attend in person or via Zoom, please '<a href=\"' + 'https://prodev.aeapdonline.org/4DCGI/TE099892111701INV&*' + '>register</a> in advance. More information about this and other upcoming TIC sessions can be found on the '<a href=\"' + 'https://sites.google.com/a/heartlandaea.org/heartland-tic/home' + '>TIC website</a>.</p>"
+ "<p>Topic: 6-12 Social Studies: Quality Instruction Using Technology</p>"
+ "<p>Date: January 12, 2017 </p>"
+ "<p>Time: 8:30am - 11:30am </p>"
+ "<p>Location: Johnston AEA</p>"
+ "<p>To Register: '<a href=\"' + 'https://prodev.aeapdonline.org/4DCGI/TE099892111701INV&*' + '>Click Here</a>. It is FREE!</p>"
+ "<p>Zoom Link: '<a href=\"' + 'https://heartlandaea.zoom.us/j/804914526' + '>https://heartlandaea.zoom.us/j/804914526</a> </p>"
+ "<p>If you are unable to attend virtually or in person, we will post videos of each presentation to '<a href=\"' + 'https://www.youtube.com/playlist?list=PLRAy7hvczWAXWKj4b6buttfLsGWLKGP8s' + '>Heartland’s YouTube Channel</a> a few days after this session. </p>"
+ "<p>Please pass this information on to all Social Studies teachers in your district or others in your building that might be interested in attending.</p>";

关于javascript - Google 表格电子邮件脚本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41287895/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com