如何从getUrl()函数重命名链接 [英] how to rename the link from the getUrl() function

查看:57
本文介绍了如何从getUrl()函数重命名链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个想要更改url链接名称的脚本.该脚本会发送一封带有文档链接的电子邮件.但是,我希望链接是单击此处",而不是显示链接地址.我该怎么做呢?这是我的代码.

I have a script that I want to change the name of the url link. The script sends an email with a link to the document. However, I want the link to be "click here" instead of showing the link address. How do I go about doing this? Here is my code.

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);
 }

推荐答案

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

You need to use the advanced arguments of the sendEmail function:

这应该有效:

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.

Where link is the actual URL that you want to be emailed.

以下是sendEMail函数文档的链接:

Here is a link to the documentation of the sendEMail function:

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

这篇关于如何从getUrl()函数重命名链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆