Script sends email

Asked

Viewed 84 times

0

I created a script in a google sheet, with the following code, which should send an email, when the type of alert is daily, and sending, which takes the email from column F, should only happen if the situation is pending (column D). However, I run the script and do not receive the email. OBS. The purpose of the script is to alert me that I have a task to do, every day.

function AlertaSimples () { 
  var sheet = SpreadsheetApp.getActive().getSheetByName('AlertaSimples');
  var startRow = 0;  // First row of data to process
  var numRows = sheet.getLastRow();
  var lastCol = sheet.getLastColumn();
  var dataRange = sheet.getRange(2, 3, numRows-startRow,lastCol).getValues();  //Get all values except the header rows

 //  var data = new Date();

  for (var i=0;i<numRows-startRow;i++){
    var auditor = dataRange[i][0]; //indice comeca em 0
    var meidas = dataRange[i][1];
    var tipoAlerta = dataRange[i][2]
    var situacao = dataRange[i][3]
    var obs = dataRange[i][4]
    var emailAddress = dataRange[i][5];

    if (tipoAlerta == 'Diario' && situacao =='Em Andamento' ) {

      var subject = "Prezado(a) " + auditor + ", o seguinte prazo: " + dataRange[i][1] + " vence em dias";

      var message = "ola"
      MailApp.sendEmail({
      to: emailAddress.toString(),
      subject: subject,
      htmlBody: message

      });
    } else {
      //não mandar email
  }
}
}

inserir a descrição da imagem aqui

  • is too vague " I don’t receive any email.", Is there an error? has debugged and checked the value of variables before sending?

  • I edited the question: The purpose of the script is to warn me that I have a task to do every day.

  • @Rogér, I understand your doubt, only you’ve stopped to see if it’s not your "email" in the column EMAIL TO REMINDER that is not correct ? I a few days ago made a spreadsheet that sends emails, if you want to take a look, let me know if you will need access, if I am not mistaken it is free for everyone: https://script.google.com/macros/d/MeHEJ8rpoWF--vXGBz4-Wszjdjoehhogb/Edit?uiv=2&mid=Acjpjvgaaxvgrlbqbjw2ok4ymmsv_2ttil6jgacgbymdxus3pqerf0moezt39yteyy9yinvtjjymzwmpm65aiyw3fj3lfwpiyaz3u6u1bwn-4LNRm6vKFgEK-3LfKcSNnp6irzyWq6id28

  • the email ta correct. Logically, to publish this question, I decided to put a fictional one. you can release the spreadsheet?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.