如何通过谷歌应用程序脚本发送时更改链接颜色

时间:2014-08-15 16:29:17

标签: google-apps-script

我在Google Apps脚本中使用GmailApp发送电子邮件

GmailApp.sendEmail(“”,EMAIL_TITLE,“”,{'cc':cc,htmlBody:newMsg});

htmlBody是在code.gs中编写的,它很简单。它只显示一个链接列表:

str + =“< h3>< li>< a href ='www.example.com'>” + strTitle +“< / h3> \ n”

我想强调一些更重要的链接。我尝试使用if语句

更改样式(例如链接颜色或背景颜色)

但是,以下都不起作用。它说代码有一个缺失的语句错误。如果删除了链接的html

中的style =“...”,则代码将起作用

1。)str =“< h3>< li>< a href ='www.example.com'style =”color:red“>” + strTitle +“< / h3> \ n”

2。)str =“< h3>< li>< a href ='www.example.com'style =”background-color:#fff0“>” + strTitle +“< / h3> \ n”

为什么呢?还有另一种改变链接风格的方法吗?

1 个答案:

答案 0 :(得分:0)

尝试这样:

function testmailHTML(){
  var strTitle = 'go to this test'
  var newMsg = "<a href='www.google.com' style=color:red /a>" + strTitle ;
  GmailApp.sendEmail("xxxxx@gmail.com",'EMAIL_TITLE', "", {htmlBody: newMsg });
}

结果如下:

enter image description here