我试图使用Mailapp.SendEmail将可点击的链接放入电子邮件中。根据我读过的其他一些答案,我已将链接分解为碎片以避免连接混淆。但是,html仍然显示为电子邮件中的文本。谁能告诉我我做错了什么?
function myFunction() {
var spreadsheet = SpreadsheetApp.getActive()
var responses = spreadsheet.getSheets()[0]
var lastContact = responses.getRange(1,13).getValue();
var tag1 = '<a href="'
var link = "docs.google.com/forms/d/e/1FAIpQLSfODcXSXa_xt1E78MM9uekSlOoCXwdy-EvVryY4RP0P0fZ_A/viewform"
var tag2 = '"> our registration page </a>';
var full = tag1+link+tag2
Logger.log(tag1+link+tag2)
if(responses.getLastRow()-1 > lastContact){
for(var i = lastContact+1; i<=responses.getLastRow()-1; i++){
MailApp.sendEmail(responses.getRange(i,4).getValue(), "Registration Confirmed: South and Southeast Queens Rising", "Hello, "+ responses.getRange(i,2).getValue() +" "+responses.getRange(i,3).getValue() + ",\n\n"
+ "Thank you for registering for our event We will be sending a detailed program for this exciting event very shortly. \n\n"
+ "We encourage you to attend the event with colleagues. To do so, please return to " + full + " to list employees, associates, and partners who will join you on September 12, 2017."
+ "We look forward to meeting you soon! \n\n"
+ "Thank you, \n"
+ "Signature"
)
}
responses.getRange(1,13).setValue(responses.getLastRow()-1)
} }
答案 0 :(得分:1)
在MailApp sendEmail()
方法中,您可以为允许使用html的设备指定使用htmlBody
选项/高级参数中的html内容。
function myFunction() {
...
var html_link = "<a href='docs.google.com/forms/d/e/1FAIpQLSfODcXSXa_xt1E78MM9uekSlOoCXwdy-EvVryY4RP0P0fZ_A/viewform'> our registration page </a>";
var html_body = "Hello, "+ responses.getRange(i,2).getValue() +" "+responses.getRange(i,3).getValue() + ",<br><br>"
+ "Thank you for registering for our event We will be sending a detailed program for this exciting event very shortly. <br><br>"
+ "We encourage you to attend the event with colleagues. To do so, please return to " + html_link + " to list employees, associates, and partners who will join you on September 12, 2017."
+ "We look forward to meeting you soon! <br><br>"
+ "Thank you, <br>"
+ "Signature"
...
MailApp.sendEmail({
to: responses.getRange(i,4).getValue(),
subject: "Registration Confirmed: South and Southeast Queens Rising",
body: "Can add a Plain Text version of the email body here for email apps that dont do html",
htmlBody: html_body
});
...
}