'Notify people when adding permissions

I use this script to add editor permissions:

function addEditor1() {     
  const check = "done";
  const ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // replace sheet name
  const rows = ss.getRange('A2:B').getValues();
  const ranges = rows.map((row, i) => {
    if (row[1] && row[3] != check) {
      DriveApp.getFileById(row[0]).addEditor(row[1]);
      return `E${i + 2}`;
    }
    return "";
  }).filter(String);
  if (ranges.length == 0) return;
  ss.getRangeList(ranges).setValue(check);
}

I want to notify each people so he can get the link and opening it from his email



Solution 1:[1]

Something like this

function addEditor1() {     
  const check = "done";
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("Sheet1"); // replace sheet name
  const rows = sh.getRange('A2:D' + sh.getLastRow()).getValues();
  const ranges = rows.map((row, i) => {
    if (row[1] && row[3] != check) {
      DriveApp.getFileById(row[0]).addEditor(row[1]);
      GmailApp.sendEmail(row[1],"Subject","message");
      return `E${i + 2}`;
    }
    return "";
  }).filter(String);
  if (ranges.length == 0) return;
  sh.getRangeList(ranges).setValue(check);
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cooper