0
votes

I have a spreadsheet that I would like to use to manage user profiles. As part of this I need to keep track of people's first aid certification and when it is due for renewal.

A copy of the sheet can be found here.

I have set up a script to email people a reminder but I cannot work out the code actually to have the script email someone when the specific date is due. Basically when the 90 day reminder cell C15 matches the current date the email sends.

Here is my current code:

function emailreminder() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Profile"); 
var subject = "First Aid Renewal";
var message = "You have 90 days until your First Aid runs out. Please renew your First Aid certification before it expires." ;
var email = sheet.getRange("B3").getValue();     
      MailApp.sendEmail({
        to: email,
        subject: subject,
        body: message,
      });
        } 
1
What research and trying have you done? - Tiw
I've looked up as many examples as i could of the same or similar questions. I've not found any examples that match what I'm looking for. All the attempts I have made so far don't work or I don't understand. If this isn't the place to ask for help then let me know and I will try to find a more appropriate place. I assumed that this is where you ask for help as many of the searches i undertook led me to this website - Chippa
Divide and conquer, split your task as two parts, condition and send mail, then research on each. This is a website for helping resolve/answer programming questions, but not a place to help you program. And as for the part "or I don't understand", why not try to understand them first? You can search those parts you don't understand on this site or ask a question when no useful posts found. - Tiw
I am trying to understand, that's why i ask for help. It's generally quicker to get somewhere when you have someone who can help point the way. But I understand the attitude of some people towards that - Chippa
Include (some of) those attempts you did and the actual results instead of don't work in your question, would be better for it gets answer. Please read how-to-ask and mcve. - Tiw

1 Answers

0
votes

You can try the following:

if(sheet.getRange("C15").getValue().setHours(0,0,0,0) == new Date().setHours(0,0,0,0)){
    GmailApp.sendEmail(email, subject, message);
  }

It is better to use GmailApp.sendEmail function