MailApp发送电子邮件htmlBody可点击的动态链接 [英] MailApp sendEmail htmlBody clickable dynamic link

查看:336
本文介绍了MailApp发送电子邮件htmlBody可点击的动态链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个脚本,它可以从原始电子表格的一个表格中创建一个新的电子表格,并通过电子邮件发送附有PDF版本的新电子表格,并带有一些带有一些文本的html正文以及指向新电子表格的链接。该脚本每天早上触发,因为该表具有动态链接数据的功能,所以链接也随每个触发器而改变。
问题是,html正文中的链接显示为文本,我希望它是可点击的。我尝试使用HREF格式化它,但似乎并没有这么做。

I wrote a script that creates a new Spreadsheet from one of the Sheets of the original Spreadsheet and emails the new Spreadsheet with the PDF version attached and has an html body with some text and the link to the new Spreadsheet. The script fires each morning because the Sheet has dynamically chaning data, so the link also changes with every trigger. The problem is that the link in the html body appears as a text and I would like it to be clickable. I tried formatting it with with A HREF but that wouldn't seem to do the trick

var napijelentes = SpreadsheetApp.create(fajlnev);
var napijelentesfajlid = napijelentes.getId();
var napijelentesfajl = DriveApp.getFileById(napijelentesfajlid);
var napijelentesurl = napijelentes.getUrl();

MailApp.sendEmail({
to: ellenorzes,
subject: subject,
htmlBody: "To download the spreadsheet please follow the link below: <br><a href = \"napijelentesurl\">" + napijelentesurl + "</a><br><br>",
attachments: [napijelentesfajl]
});

通过这种方式,链接以纯文本形式出现在电子邮件中,其前面有[napijelentesurl]仍然无法点击。
我的问题的任何解决方案?

This way the link appears in the email as plain text, with [napijelentesurl] in front of it and is still not clickable. Any solutions to my problem?

推荐答案

为html字符串创建一个变量。

Create a variable for the html string.

var h;
h = 'To download <br><a href = "' + napijelentesurl + '">' + 
     napijelentesurl + "</a><br><br>"; 

在字符串末尾使用单引号,需要双引号。

Use single quotes on the ends of string that need double quotes inside the string.

这篇关于MailApp发送电子邮件htmlBody可点击的动态链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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