title: Is it possible to insert a dynamic link into an email using only JavaScript and no HTML? (Using Google Script to sent the email)
body: <p>Need to preface this with an edit, I'm not using Javascript in the actual email. I'm using Javascript in Google Script which I run to send the email.</p>
  
  <p>I don't really know anything about using html/js in emails, but my roommate needed help inserting a dynamic link using JavaScript into his email using Google Sheets (a .gs file), so I found the code to do it, but the problem is the JavaScript still uses HTML for the dynamic link. </p>
  
  <p>What I found was this</p>
  
  <pre><code>var str = "TEXT FOR LINK"
  var link = str.link("http://LINKGOESHERE")
  </code></pre>
  
  <p>Running this works perfectly as it should. However, the rest of his email was entirely JavaScript, so JavaScript used this code to insert the following HTML code: </p>
  
  <pre><code>&lt;a href="http://LINKGOESHERE"&gt;TEXT FOR LINK&lt;/a&gt;
  </code></pre>
  
  <p>Since we are running this as a .gs file (Google Sheets), I was wondering if there was a way of just inserting the dynamic link without using any HTML at all, or if we simply need to wrap everything in HTML (and if so, how does that work with an email being sent by running a .gs file).</p>
  
  <p>Here is what the .gs file looks like with the main text and info replaced with gibberish:</p>
  
  <pre><code>function sendEmails() {
  var str = "TEXT FOR LINK"
  var link = str.link("http://LINKGOESHERE")
  
  var senderEmail = 'SOMEONESEMAILADDRESS@email.com';
  link.onclick = function() {
      this.href = "mailto:"+senderEmail;
  };
    var sheet = SpreadsheetApp.getActiveSheet();
    var startRow = 2; 
    var numRows = sheet.getLastRow()-1;
    var dataRange = sheet.getRange(startRow, 1, numRows, 2);
    var data = dataRange.getValues();
  
    var sender = 'MyName';
    var body = '\n\nTEXT BLABLABLABLABLA'+link+' TEXTBLABLABLABLA';
    var subject = 'SUBJECT';
    var options = {replyTo: senderEmail , from: senderEmail, name: sender};
  
    for (var i = 0; i &lt; data.length; ++i) {
      var row = data[i];
      var emailAddress = row[0];
      var firstName = row[1];
      var message = 'Hi ' + firstName + ',' + body;
  
  
      MailApp.sendEmail(emailAddress, subject, message, options);
    }
  }
  </code></pre>