简体   繁体   中英

Highlighting text in a google sheet cell using HTML and google apps script

I am relatively new to scripts and code and am trying to learn some new skills but what I need here is very confusing.

I have a script running which is essentially an independent mail merge. It references a cell in my google doc as a template, which has been formatted as HTML. In this template, I have a footer to the email which is a quote that I would like to be highlighted when the email is sent out.

Here is the script;

  function sendEmail() { 
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Emails").activate();

var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lr = ss.getLastRow();

var templateText = 
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("EmailTemplates").getRange(1, 1).getValue();

var quotaLeft = MailApp.getRemainingDailyQuota();

if((lr-1) > quotaLeft){
Browser.msgBox("You have " + quotaLeft + " email quota left for the day and you are trying to send " + (lr-1) + " emails. 0 emails were sent"); 
} else {

for (var i = 3;i<=lr;i++){

var currentEmail = ss.getRange(i, 4).getValue();
var SiteURL = ss.getRange(i, 5).getValue();
var FirstName = ss.getRange(i, 2).getValue();

var messageBody = templateText.replace("{{First Name}}",FirstName);
var subjectline = "Looking to partner with " + ;
var imageUrl = "place site url here"

var htmlBody = messageBody + "<br><img src='" + imageUrl + "'>";

MailApp.sendEmail(currentEmail, subjectline, messageBody, {htmlBody: htmlBody});



} // close for loop

}  // close else statement

}

The footer of the email which I would like to be highlighted is this;

“Google only loves you when everyone else loves you first”

Is this possible?

+"<p style='color: purple'>Google only loves you when everyone else loves you first</p>";

这使我只能更改文本颜色

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM