Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendEmailIfValueLessThan30() {
- // Declare variables
- var cells = SpreadsheetApp.getActive().getRange("D4:D6");
- var values = cells.getValues();
- var recipients = ["[email protected]", "[email protected]"];
- var subject = "končí";
- var body = "";
- // Loop through the cells and check if the value is less than 30
- for (var i = 0; i < values.length; i++) {
- if (values[i] == 30) {
- var name = SpreadsheetApp.getActive().getRange("B" + (i + 4)).getValue();
- body += "někomu " + name + " má " + values[i] + " konec.\n";
- }
- }
- // If there are any values less than 30, send an email
- if (body.length > 0) {
- for (var recipient of recipients) {
- MailApp.sendEmail(recipient, subject, body);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment