Scroll to Top
💻
Free Code
Users get ready-to-use code at no cost.
📋
Easy Copy
Copy and use the code instantly.
Quick Learning
Understand concepts fast and clearly.
📝
Step-by-Step
Follow simple instructions to implement.
📅 September 3, 2024 💻 Tutorial ⭐ Beginner Friendly

Get Notified about Google Spreadsheet Changes | Google Apps script!

Author Avatar

Ashish Dwivedi

Editorial Team • Tech Writer

About This Tutorial

Stay informed with real-time alerts whenever changes are made to your Google Spreadsheet. Whether it’s edits, additions, or deletions, you’ll get notified instantly—perfect for team collaboration, tracking data updates, or staying on top of shared project sheets.
  1. Step 1: Click on the Copy button to copy the code snippet.
  2. Step 2: Paste the copied code into your project’s script editor.

Apps Scripts Blog

Read Blog

📂 javascript
⚡ script1.js
⚡ script1.js
function sendEmailOnEdit(e) {
  if (!e) return;
  var sheet = e.source.getActiveSheet();
  var sheetName = sheet.getName();
  var recipients = "sharma.mohit@outrightcrm.com";
  var subject = "Someone Edited a Google Sheet";
  var body = "The Google Sheet named '" + sheetName + "' was edited. ";

  // Get the user who made the edit
  var user = Session.getActiveUser().getEmail();

  // Get the range of the edited cell
  var range = e.range;
  var row = range.getRow();
  var column = range.getColumn();

  // Get the new value of the edited cell
  var newValue = e.value;

  var header = "<table style='border-collapse: collapse;'><tr>" +
    "<th style='border: 1px solid black; padding: 5px;'>User</th>" +
    "<th style='border: 1px solid black; padding: 5px;'>Row</th>" +
    "<th style='border: 1px solid black; padding: 5px;'>Column</th>" +
    "<th style='border: 1px solid black; padding: 5px;'>Value</th>" +
    "<th style='border: 1px solid black; padding: 5px;'>Date/Time</th>" +
    "</tr>";

  // Construct the table row
  var rowHtml = "<tr>" +
    "<td style='border: 1px solid black; padding: 5px;'>" + user + "</td>" +
    "<td style='border: 1px solid black; padding: 5px;'>" + row + "</td>" +
    "<td style='border: 1px solid black; padding: 5px;'>" + column + "</td>" +
    "<td style='border: 1px solid black; padding: 5px;'>" + newValue + "</td>" +
    "<td style='border: 1px solid black; padding: 5px;'>" + new Date().toLocaleString() + "</td>" +
    "</tr>";

  var footer = "</table>";

  document.getElementById("output").innerHTML = header + rowHtml + footer;
}