0
I have the following code that sends emails through a Google spreadsheet.
function sendEmails() {
var sheet = SpreadsheetApp.getActive();
var startRow = 2;
var planMensagens = sheet.getSheetByName("mensagensEmail");
var mensagemRef = planMensagens.getRange(2,3);
var mensagem = mensagemRef.getValue();
var tituloRef = planMensagens.getRange(2, 2);
var titulo = tituloRef.getValue();
//buscar valores para a linha no intervalo
var data = sheet.getRange("base!A2:D4").getValues();
for(i in data){
var validaEnvio = "N";
var row = data [i];
var emailAddress = row [2]; //email
var jaEnviouRef = row [3]; //coluna de referencia para envio
if(jaEnviouRef == "" && emailAddress != "") {
//função para enviar os emails
MailApp.sendEmail(emailAddress, titulo, mensagem);
//PESQUINAR COMO ATUALIZAR O CAMPO PARA NÃO ENVIAR O MESMO EMAIL
}
}
}
Problem:
When I send the email I have to update a cell with the character "S", so that when it passes the
if(jaEnviouRef == "" && emailAddress !="")
It does not execute the code.
I’m not getting to set the value.
Hello @Filipetd, The problem is that this way I can’t automate the action. I tried something like this, but without success. sheet.getRange(Row[3]). setValue("S");
– Kennedy Anderson
Your question is duplicated. Take a look at this topic. https://answall.com/questions/235391/script-para-abertura-called-pelo-google-forms/239701#239701
– FilipeTD