0
votes

I am sending an email using GmailApp in Google Apps Script

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

The htmlBody is written within code.gs and it is a simple one. it just shows a list of links:

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

As I would like to emphasize certain more important links. I tried to change the style (e.g. link colour or background colour) using an if statement

However,none of the following works. it says the code has a missing statement bug. The codes will work if style="..." is removed the link's html

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:#ffffa0">" + strTitle + "< /h3>\n"

Why? is there another way to change the style of thelinks?

1

1 Answers

0
votes

try simply like this :

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

result below :

enter image description here