Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.

Send email notifications based on the expiry dates entered in a column of Google Sheets

We use Sheets for assets that have expiry dates. Is it possible to send email notifications to a user "x" days before the expiry date of each asset? All the expiry dates will in under column D in the test sheet below. 

 

https://docs.google.com/spreadsheets/d/1ea-cTC16C4UBdGTCchwEG9iY1qM48kv2kfY0XJ7_iqQ/edit?usp=sharing

Solved Solved
1 2 3,401
1 ACCEPTED SOLUTION

This is resolved. Gemini can create a script by linking Google Sheets with Apps Script.  A sample below.
Sheets > Extensions > Apps Script and copy the below lines or Gemini's suggested script. Then set Triggers in the Apps Script, for e.g. first day of every month to check the sheet and trigger reminder emails based on the dates on column B.

 
function sendReminders() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const range = sheet.getRange("A2:B"); // Adjust the range to your needs
  const values = range.getValues();

  for (let i = 0; i < values.length; i++) {
    const dateCell = values[i][1]; // Assuming date is in column B
    const date = new Date(dateCell);

    if (date.getTime() <= Date.now()) {
      const emailAddress = "email@gmail.com"; // Replace with your email
      const subject = "Reminder " + values[i][0]; // Assuming task is in column A
      const body = "This is a reminder for an item expiring soon in the Google Sheets file name  for " + values[i][0];

      GmailApp.sendEmail(emailAddress, subject, body);
    }
  }
}
 
 
Screenshot_8.png

View solution in original post

2 REPLIES 2
Top Labels in this Space