Google Sheets: sendEmail() with day exceptions

Hi! I’m new in this forum.
I was able to send rows from a Google Sheet via e-mail, using the Javascript sendEmail() function. The aforementioned Google Sheet is linked to a Google Form.


In the sheet, under the column "Recursive_Requests ", there are 2 options to send data. I would want that:

  1. if you select "send_every_day " option, the request is sent by e-mail every day;
  2. if you select "send_every_monday ", the request remains in the sheet, BUT it is sent only every Monday;
  3. if you select "No ", no changes are made.

Any help would be appreciated!


Code used:

function sendEmail() {
  var orderData = getData();
  var body = getEmailText(orderData);

  MailApp.sendEmail({
    to: "email@example.com",
    cc: "anotheremail@example.com",
    subject: "Today's orders",
    body: body
  });
}

function getEmailText(orderData) {
  var text = "";
  orderData.forEach(function(order) {
    text = text + order.department + "\n" + order.request + "\n-----------------------\n\n";
  });
  return text;
}

/**
 * @OnlyCurrentDoc
 */
function getData() {
  var values = SpreadsheetApp.getActive().getSheetByName("Form responses 1").getRange("Orders_NamedRange").getValues();
  values.shift();
  var orders = [];
  values.forEach(function(value) {
    var order = {};
    order.department = value[1];
    order.request = value[2];
    orders.push(order);
  })
  //Logger.log(JSON.stringify(stocks));
  return orders;
}

My Google Formclick here
My Google Sheetclick here

Hi @Michael_Benton,

Welcome to the community!

Your question would be best suited for a Google support forum.

Please let us know if you have any questions about the monday GraphQL API, Apps Framework, SDK, or monday.com in general :slight_smile:

I see. Anyway, thanks for your suggestion! I’ve asked on StackOverflow.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.