Javascript 使用Google脚本将文本更改为粗体或添加图像
这是我到目前为止的代码,它工作得很好!我只是想知道如何将文本改为粗体,如果可能的话,添加图片。对于它所说的增长,发光,适当的地方。例如,我想用粗体字Javascript 使用Google脚本将文本更改为粗体或添加图像,javascript,text,google-apps-script,macros,Javascript,Text,Google Apps Script,Macros,这是我到目前为止的代码,它工作得很好!我只是想知道如何将文本改为粗体,如果可能的话,添加图片。对于它所说的增长,发光,适当的地方。例如,我想用粗体字 function sendEmails() { var allData,counter,emailAddress,fourRowsOfData,i,lastRow, message,messageStart,messageEnd,numRows, row,sheet,startRow,studentName
function sendEmails() {
var allData,counter,emailAddress,fourRowsOfData,i,lastRow,
message,messageStart,messageEnd,numRows,
row,sheet,startRow,studentName,subject;
//USER INPUT
startRow = 2; // First row of data to process
numRows = 4; // Number of rows to process
subject = "Camp Pursuit: Report Card ";
messageStart = "Dear Parents,"+'\n' +'\n' +
"Every week at Camp Pursuit, we ask the teachers to make observations about how the kiddos did." +'\n' +
"We know that one week isn't enough to truly know a child, so we call this our " +"Glows, Grows, & Apropos." +'\n' +
"Meaning..." + '\n' +'\n' +
"Glows: Positive things the teacher noticed" +'\n' +
"Grows: Areas for continued growth" +'\n' +
"Apropos: Ways to continue your son/daughter's enrichment" +'\n' +
"We hope you appreciate seeing what the teachers saw last week, and perhaps you can use some of"+'\n' +
"the recommendations for further enrichment this summer. Feel free to let us know your thoughts on the camp through our anonymous online survey."+'\n' +
"Your feedback helps us improve the experience for all kiddos! "+'\n' +
"Survey Link: https://docs.google.com/forms/d/1g4LvA9a8sdKECr1yvp5uOoPnvKACFm3HvbTBfvQGRyo/viewform?usp=send_form" +'\n' +
"We look forward to seeing your child at our programs throughout the year!" +'\n' +
"Sincerely, "+'\n' +
"The Camp Pursuit Team"
+'\n';
//END USER INPUT
sheet = SpreadsheetApp.getActiveSheet();
lastRow = sheet.getLastRow();
allData = sheet.getRange(startRow, 1, lastRow-startRow, 10);// Get All data first
counter = 0;
while (counter < lastRow-startRow) {
Logger.log('counter: ' + counter)
fourRowsOfData = sheet.getRange(startRow + counter, 1, numRows, 6).getValues();
emailAddress = fourRowsOfData[0][0]; // First column of first row
Logger.log('emailAddress: ' + emailAddress)
studentName = fourRowsOfData[0][1];
messageEnd = "";//Reset on every outer loop
for (i = 0; i < numRows; i++) {//loop numRows times - once for each row
row = fourRowsOfData[i];
messageEnd = messageEnd + '\n' +
"Class: " + row[2] + '\n' +'\n' +
"Glows: " + row[3]+ '\n' +
"Grows: " + row[4] +'\n' +
"Apropos: " + row[5] +'\n';
}
message = messageStart + "\n" + studentName + "\n" + messageEnd;
MailApp.sendEmail(emailAddress, subject, message);//Send the email outside of inner loop
counter+=numRows;//Increment counter by number of rows to process
}
}
函数sendEmails(){
var allData、计数器、电子邮件地址、四行SOFDATA、i、最后一行、,
message,messageStart,messageEnd,numRows,
行、表、起始行、学生姓名、科目;
//用户输入
startRow=2;//要处理的第一行数据
numRows=4;//要处理的行数
主题=“营地追踪:成绩单”;
messageStart=“亲爱的父母,”+'\n'+'\n'+
“每周在追踪营,我们都要求老师观察孩子们的表现。”+“\n”+
“我们知道一个星期不足以真正了解一个孩子,所以我们称之为我们的“+”发光、生长和适当。”+'\n”+
“意思是…”+'\n'+'\n”+
“发光:老师注意到的积极事物”+'\n”+
“增长:持续增长的区域”+“\n”+
“恰当:继续让您的儿子/女儿充实的方法”+'\n”+
“我们希望您能欣赏老师上周看到的内容,或许您可以使用“+”\n”+
“今年夏天进一步充实的建议。请随时通过我们的匿名在线调查让我们知道您对夏令营的看法。”+'\n”+
“您的反馈帮助我们改善所有孩子的体验!”+“\n”
“调查链接:https://docs.google.com/forms/d/1g4LvA9a8sdKECr1yvp5uOoPnvKACFm3HvbTBfvQGRyo/viewform?usp=send_form“+”\n”+
“我们期待您的孩子全年参加我们的节目!”+“\n”+
“真诚地,“+”\n”+
“营地追捕队”
+“\n”;
//最终用户输入
sheet=SpreadsheetApp.getActiveSheet();
lastRow=sheet.getLastRow();
allData=sheet.getRange(startRow,1,lastRow startRow,10);//首先获取所有数据
计数器=0;
while(计数器function sendEmail() {
var body = "<b>Hello </b> world. <i><Hello /i> world. <br /> New line";
MailApp.sendEmail("anton.dementyev@gmail.com", "test", "", {htmlBody: body});
}
函数sendmail(){
var body=“Hello world.world.新行”; MailApp.sendmail(“安东。dementyev@gmail.com“,”测试“,”,{htmlBody:body}); }
请参阅此处的“高级参数”部分在消息字符串中使用标准html标记,然后在sendmail()方法中将空字符串“”或“null”作为正文参数传递。最后,将消息字符串指定给“options”参数的“htmlBody”属性。对换行符使用“br”标记。范例
function sendEmail() {
var body = "<b>Hello </b> world. <i><Hello /i> world. <br /> New line";
MailApp.sendEmail("anton.dementyev@gmail.com", "test", "", {htmlBody: body});
}
函数sendmail(){
var body=“Hello world.world.新行”; MailApp.sendmail(“安东。dementyev@gmail.com“,”测试“,”,{htmlBody:body}); } 请参阅此处的“高级参数”部分根据官方文档,要发送HTML正文,您需要在
MailApp.sendmail()方法中使用htmlBody
参数。请看下面的示例(从官方文档页面复制)
要使文本加粗,请使用
标记
例如:“此文本将以粗体显示
要在电子邮件中显示图像,请使用
MailApp.sendEmail({
to: "recipient@example.com",
subject: "Logos",
htmlBody: "inline Google Logo<img src='URL_PATH'> images! <br>" +
"inline YouTube Logo <img src='URL_PATH'><br>" +
"<b>Using bold tag</b> ",
inlineImages:
{
googleLogo: googleLogoBlob,
youtubeLogo: youtubeLogoBlob
}
});
MailApp.sendmail({
至:recipient@example.com",
主题:“徽标”,
htmlBody:“内嵌谷歌徽标图像!
”+
“内嵌YouTube徽标
”+
“使用粗体标记”,
在线图像:
{
googleLogo:googleLogoBlob,
youtubeLogo:youtubeLogoBlob
}
});
希望这有帮助。根据官方文档,要发送HTML正文,您需要在MailApp.sendmail()方法中使用htmlBody
参数。请看下面的示例(从官方文档页面复制)
要使文本加粗,请使用
标记
例如:“此文本将以粗体显示
要在电子邮件中显示图像,请使用
MailApp.sendEmail({
to: "recipient@example.com",
subject: "Logos",
htmlBody: "inline Google Logo<img src='URL_PATH'> images! <br>" +
"inline YouTube Logo <img src='URL_PATH'><br>" +
"<b>Using bold tag</b> ",
inlineImages:
{
googleLogo: googleLogoBlob,
youtubeLogo: youtubeLogoBlob
}
});
MailApp.sendmail({
至:recipient@example.com",
主题:“徽标”,
htmlBody:“内嵌谷歌徽标图像!
”+
“内嵌YouTube徽标
”+
“使用粗体标记”,
在线图像:
{
googleLogo:googleLogoBlob,
youtubeLogo:youtubeLogoBlob
}
});
希望这能有所帮助。当我添加它时,它会发送带有而不是boldedI的电子邮件,所以当它说。我的目标是让发光,增长,适当的文本加粗。“发光:老师注意到的积极的事情”+'\n'+“增长:持续增长的领域”+'\n'+“Apropos:Ways to continue to continuent your son/Darl’s Enrich”当我添加它时,它会发送带有的电子邮件,而不是boldedI posted,所以当它说。我的目标是让发光,增长,适当的文本加粗。发光:老师注意到的积极事物“+”\n“+”增长:持续增长的区域“+”\n“+”