creating email reminder 30 days prior from google sheet date

Hello I currently have a google sheet with dates of certs that expire on different days. I would like to set up an email alert for 30 days prior to the entered date in each cell.

is this possible? I tried to figure it out with the conditional notifications but seems like its not possible through that and will have to be done with coding it through the google scripts.

Please advise.

photo attached of column of dates:

Set 30 days email notification

You can try this.

This code will effectively go through the dates written in your Google sheets then checks if the date is 30 days from the current date then if it is, the script will send an email.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>function myFunction() {
// Gets your current active spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Declaration of the range to be used in the spreadsheet and its values. Kindly change `A2:A` with the range where your dates are in the screenshot
var rg = ss.getRange("A2:A").getValues();
// 30 days from today
var td = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 30, 0, 0, 0);
// Loops through the rows and sends emails if today is 30 days from the dates in Column A
rg.forEach(r => {
var cd = new Date(r[0]);
cd.getTime() == td.getTime() ? MailApp.sendEmail("<email-address-here>", "Due date reminder", `This is a reminder that ${cd.toLocaleDateString()} is 30 days from today.`) : null;
});
}
</code>
<code>function myFunction() { // Gets your current active spreadsheet var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); // Declaration of the range to be used in the spreadsheet and its values. Kindly change `A2:A` with the range where your dates are in the screenshot var rg = ss.getRange("A2:A").getValues(); // 30 days from today var td = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 30, 0, 0, 0); // Loops through the rows and sends emails if today is 30 days from the dates in Column A rg.forEach(r => { var cd = new Date(r[0]); cd.getTime() == td.getTime() ? MailApp.sendEmail("<email-address-here>", "Due date reminder", `This is a reminder that ${cd.toLocaleDateString()} is 30 days from today.`) : null; }); } </code>
function myFunction() {
  // Gets your current active spreadsheet
  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  // Declaration of the range to be used in the spreadsheet and its values. Kindly change `A2:A` with the range where your dates are in the screenshot
  var rg = ss.getRange("A2:A").getValues();
  // 30 days from today
  var td = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 30, 0, 0, 0);
  // Loops through the rows and sends emails if today is 30 days from the dates in Column A
  rg.forEach(r => {
    var cd = new Date(r[0]);
    cd.getTime() == td.getTime() ? MailApp.sendEmail("<email-address-here>", "Due date reminder", `This is a reminder that ${cd.toLocaleDateString()} is 30 days from today.`) : null;
  });
}

Set-up a container-bound script

To set-up a Google Apps Script that is connected to the Google sheet where the dates are present, follow these steps:
Open the Google sheet file>From the navigation at the top, click “Extensions”>Choose Apps Script>An Apps Script editor browser window will open> This is where you will paste the code above and where you will set-up a time-driven event trigger.

Set-up time-driven trigger on Apps Script

To set-up an automatic email notification, you must first set-up a time-driven event that is set to fire everyday but the code will still check if the current date is 30 days from the date present on your sheet before sending an email notification. You can follow these steps on setting-up time-driven event trigger on Google Apps Script.

1.) Click on triggers (Clock icon on the left side of your screen)
2.) Click “Add Triggers”
3.) On the option that says “Choose which function to run
” choose the name of the function, in my given code’s case the function name is “myFunction”
4.) On the “Choose which deployment should run
” choose “Head”
5.) “Select event source” choose “Time-driven”
6.) “Select type of time based trigger
” choose “Day timer”
7.) For the option that says “Select time of day
” select your preferred time
8.) Click save button

Images for further reference:

Sample Output

References

Installable triggers

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật