jeudi 5 octobre 2023

Keep Font Color when Sending an Automated Gmail Message

We currently have an apps script that is sending an automated email when a checkbox is checked in Google Sheets. We have a "Message" column that the apps script is pulling from to create the body of the email. When the email sends, the entire body is just plain text. I want to be able to make some of the text in the "Message" column red and some text black (within the same cell) and then have it send the email with corresponding red and black text. Can this be done? I am attaching the apps script below:

function onCheckboxEdit(e) {
  var source = e.source
  var sheet = source.getActiveSheet();
  var range = e.range
  var row = range.getRow();
  var column = range.getColumn();
  console.log("column:: ", column);

  var targetRange = sheet.getRange( row, 1, 1, 5)
  var targetValues = targetRange.getValues();
  console.log("targetRange:: ", targetValues);
  var recipient = targetValues[0][2];
  var checkboxValue = targetValues[0][3];
  var body = targetValues[0][4];;
  var subject = "New Traveler Coverage Update"
  var cc = targetValues[0][5]

  if(column = 4 && checkboxValue == true) {
    console.log("checkbox marked true")

    GmailApp.sendEmail(recipient, subject, body, {
      cc: "operations@milanlaser.com"
    });

  } else if (column = 4 && checkboxValue == false) {
    console.log("checkbox marked false")
  } else {
    console.log("No clue")
  }
}

This is the link to the video where we got the apps script: https://www.youtube.com/watch?v=v_DCrKkzRSg

Everything I have found does not incorporate the checkbox trigger




Aucun commentaire:

Enregistrer un commentaire