Insert text with hyperlink in Gmail with Google Script?
<p>I am trying to send an email with an attachment and the URL of the attachment. The email body would look like this:</p>

<p>"Hi Everyone-</p>

<p>Here's the <a href="http://google.com" rel="noreferrer">agenda</a> for tomorrow's meeting.  </p>

<p>See you in the morning!</p>

<p>-John Doe"</p>

<p>I have written the code to my best ability. I know I wrote the bottom half erroneously. Please assist. </p>

<pre><code>  function sendEmailTest() {
  //test send email.
  // Send an email with an attachment: a file from Google Drive.
    var file = DocumentApp.openById(file2.getId());
    var ssUrl = 'URL_BUFFERED';
    var sheetName = 'Sheet1';   // name of sheet to use
    var rangeName = 'C30';    // range of values to include 
    var dateRange = SpreadsheetApp.openByUrl(ssUrl)
       .getSheetByName(sheetName)
       .getRange(rangeName)
       .getValues();

  // Name of Google file to attach.
    var file2 = file.makeCopy('Weekly Agenda | '+dateRange);

  // Set Agenda URL.
    var theBody = GmailApp.openById(file2.getId()).getBody();
    var elementReplaced = theBody.replaceText("%toReplace%", "agendaURL");
    elementReplaced.asText().setLinkUrl("https://google.com");

  //Send email.
        MailApp.sendEmail('who@whowantstoknow.com', file2, 'Hi Everyone- \n Here\'s the ' +agendaURL+'agenda for tomorrow
                   's meeting. \n See you in the morning! \n-John Doe', {
        name: 'Automatic Emailer Script',
        attachments: [file.getAs(file2)] });
}
</code></pre>