如何从 getUrl() 函数重命名链接



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

function sendDoc() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var url = ss.getUrl(); 
var body = "Hi Bo,nnHere are the weekly stats " + url;
var thanks = "nnThank You,n   Chris";
var message = body + thanks; 
MailApp.sendEmail(email, subject, message);
 }

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

这应该有效:

function sendDoc() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var url = ss.getUrl(); 
var body = "Hi Bo,nnHere are the weekly stats " + url;
var thanks = "nnThank 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

最新更新