调用 HTML 消息中的变量并为其着色



我:)寻求您的帮助如何调用"var 消息"中的所有变量并为其着色?我现在对消息使用常规字符串类型,但我想使用 HTML 文本来更改字体大小和颜色。我是代码的结尾,你有我的错误版本的文本:)

提前致谢

function sendEmails() {
var sheet = 
SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var data = rows.getValues();
for (i in data) {
  var row = data[i];
  var currentShop = row[7] - 200000;
  var expectedShop = row[1] - 200000;
if(row[12] == "PL") {
  var Package = "Pilnie C&C-" + row[0];
} else {
    var Package = "Urgent C&C-" + row[0];
       }
var emailAddress = currentShop + "@gmail.com, " + expectedShop + "@gmail.com" ;
if(row[12] == "PL") {
  var message = "Drogi sklepie..... "
    } else {
      var message = "Hello shop " + currentShop + " (" + row[12] + ")," + 'nn' + "according to the information in the system," + 'n' + "the parcel num. " + row[0] + 'n' + "was delivered to YOUR shop instead of to the correct one " + expectedShop + "(" + row[6] + ")." + 'n' + "Please check it and answer this e-mail. The parcel should be sent to the correct shop." + 'n' + "In case of any questions, please, contact me;
           }
MailApp.sendEmail(emailAddress, Package, message);
   }
};
<html>
<body>
Drogi sklepie <span style='color:red; '><strong><?= currentShop;?> ( <?=row[12];?> )</strong>,</span> <br><br>
wedle informacji z systemu, <br>
zamówienie <span style='color:orange; '><strong>nr <?=row[0];?></strong></span> <br> 
zamiast Waszego sklepu, powinno byæ przes³ane kurierem do sklepu <span style='color:green; '><strong><?=expectedShop;?> (<?=row[6];?>)</strong></span>. <br>
Proszê o sprawdzenie tego i odpowiedzenie na ten e-mail. <br>
W przypadku pytañ, proszê o kontakt ze mną
</body>
</html>
如果我

理解正确,您希望消息的HTML格式正文,对吗?如果是这样,您应该options参数添加到MailApp.sendEmail()调用中(有关详细信息,请参阅MailApp参考(,设置其htmlBody属性并将HtmlString写入它(或者,您可以通过HtmlService.createTemplateFromFile(yourFileName).evaluate()写入它,因为您使用的是模板变量(

最新更新