Pass variable to href tag within body of an email

First time posting, although I have spent many a moon lurking around the site. I was unable to find if anyone had a similar post and thus I am posting to see if someone can answer this question for me.

I am trying to embed a hyperlink into the body of an email. I am taking data from a specific cell from a sheet

var n = ws.getRange("A2").getDisplayValue();
var data1 = ws.getRange("L2").getDisplayValue();

and want to pass that variable, data1, to an html template to embed into a specific href tag URL within the template to mail out.

var temp= HtmlService.createTemplateFromFile("xyz");

temp.name = n;

var htmlMessage = temp.evaluate().getContent();
  GmailApp.sendEmail(
      Email, 
      Subject,"Your email doesn't support HTML.", 
      {name: "AD", htmlBody: htmlMessage}
    );

Example html file "xyz":

<p>Hi, <?= name ?>,</p>

<p>Please see attached <a href="data1">link</a></p>

How would I go about passing the variable into the tag? Thanks in advance!

27 thoughts on “Pass variable to href tag within body of an email”

  1. 147891 104068Wow, wonderful weblog structure! How long have you been running a weblog for? you created running a weblog look straightforward. The whole look of your internet site is magnificent, neatly as the content material material! 264697

    Reply
  2. 116189 617911I dont think Ive seen all the angles of this subject the way youve pointed them out. Youre a true star, a rock star man. Youve got so considerably to say and know so considerably about the topic that I believe you ought to just teach a class about it 718221

    Reply

Leave a Comment