Reputation: 1
I'm asking for your help :) How could I call and color all variables inside the "var message"? I'm using regular string type for message for now but I would like to use HTML text with ability to change font size and color. I'm the end of the code you have my bad version of that text :)
Thanks in advance
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] + ")," + '\n\n' + "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>
Upvotes: 0
Views: 51
Reputation: 10345
If I understand you correctly, you want HTML-formatted body for the message, right? If so, you should add options
argument to MailApp.sendEmail()
call (see the MailApp
reference for details), set its htmlBody
property and write your HtmlString
to it (alternatively, you can write it in via HtmlService.createTemplateFromFile(yourFileName).evaluate()
, since you are using template variables)
Upvotes: 1