[英]I'm trying to send an email from google spreadsheet, however the message is not copying the hyperlink
I have "to" in column A & "message/body" in column "B".我在 A 列中有“to”,在“B”列中有“message/body”。 I have a code which sends an email.
我有一个发送 email 的代码。 However in my message I have a word hyperlinked to another sheet, while sending the email, the hyperlink is not considered.
但是,在我的消息中,我有一个超链接到另一张纸的单词,在发送 email 时,不考虑超链接。 Please find the screenshot below.
请在下面找到屏幕截图。
However when the email is sent, the hyperlink is not visible.但是,当发送 email 时,超链接不可见。 Please the image below
请看下图
function sendEmails() {
var sheet = SpreadsheetApp.getActiveSheet();
var startRow = 2;
var numRows = 1;
var dataRange = sheet.getRange(startRow, 1, numRows, 2);
var data = dataRange.getValues();
for (var i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var subject = 'Sending emails from a Spreadsheet';
MailApp.sendEmail(emailAddress, subject, message);
}
}
var htmlBody = HtmlService.createTemplate('Email with <a href=<?=link?>> Some link </a>');
htmlBody.link = row[1];
MailApp.sendEmail({
to: row[0],
subject: 'Sending emails from a Spreadsheet',
htmlBody: htmlBody.evaluate().getContent()
});
If you have embedded cell links, you can extract them using Advanced Sheets services, as describe here , for example如果您有嵌入的单元格链接,您可以使用高级表格服务提取它们,如此处所述,例如
var values = Sheets.Spreadsheets.get(SpreadsheetApp.getActive().getId(), {ranges: "Sheet1!B1:B10", fields: "sheets/data/rowData/values/hyperlink"})
var links = values.sheets[0].data[0].rowData.map(v => v.values[0].hyperlink);
them use them in templated HTML example I provided.他们在我提供的模板化 HTML 示例中使用它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.