I am in the middle of a mail merge project, and have created a google sheet that includes all of my standard fields. One field includes a hyperlink. In my current code I am only able to pass the text for the hyperlink into gmail. Below are the HTML code and google app script that I am working with. I suspect that I need to modify my HTML code but I am uncertain how to proceed. The HTML codes in question is <?= fs ?>
. Any support would be greatly appreciated.
HTML Code:
<body>
<p>Please review and update your project management spreadsheet by [insert date] using the link: <?= fs ?></p>
</body>
Google Apps Script
function myFunction() {
var school = 0;
var contact = 2;
var email = 5;
var followUpSheet = 6;
var emailTemp = HtmlService.createTemplateFromFile("File_name");
var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet_Name");
var data = ws.getRange("A2:P" + ws.getLastRow()).getValues();
data.forEach(function(row){
emailTemp.contact = row[contact];
emailTemp.fs = row[followUpSheet];
var htmlMessage = emailTemp.evaluate().getContent();
GmailApp.sendEmail(
row[email],
"Name of eMail",
"Your email doesn't support HTML.",
{name: "name of sender", htmlBody: htmlMessage});
});
}
The output for this code is:
Please review and update your project management spreadsheet by [insert date] using the link: hyperlink text name
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…