1

我有一个脚本,我想更改 url 链接的名称。该脚本会发送一封电子邮件,其中包含指向该文档的链接。但是,我希望链接是“单击此处”而不是显示链接地址。我该怎么做呢?这是我的代码。

function sendDoc() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var url = ss.getUrl(); 
var body = "Hi Bo,\n\nHere are the weekly stats " + url;
var thanks = "\n\nThank You,\n   Chris";
var message = body + thanks; 

MailApp.sendEmail(email, subject, message);
 }
4

1 回答 1

3

您需要使用 sendEmail 函数的高级参数:

这应该有效:

function sendDoc() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var url = ss.getUrl(); 
var body = "Hi Bo,\n\nHere are the weekly stats " + url;
var thanks = "\n\nThank You,\n   Chris";
var message = body + thanks; 

MailApp.sendEmail(email, subject, message, {htmlBody: message.replace('link', '<a href="link">click here</a>')});
 }

其中链接是您希望通过电子邮件发送的实际 URL。

这是 sendEMail 函数文档的链接:

https://developers.google.com/apps-script/class_mailapp#sendEmail

于 2012-10-13T07:37:28.407 回答