Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Email is not sending

Code Runs No Errors But I Do Not Receive and email when I check my gmail

This line is the issue I believe I am writing this incorrectly so its not sending the email help please

if(values.getDisplayValues() === "On-going" || values.getDisplayValues() === "" && values1.getDisplayValues() >= 80)

Rest of the code:

function sendEmail(){

var ss = SpreadsheetApp.getActiveSpreadsheet();
var SpreadsheetID = ss.getSheetId(); 
var spreadsheetURL = ss.getUrl(); 
var SpreadsheetID = spreadsheetURL.split("/")[5]; 
var filterViewName = 'PO_Log Precentage'; 
var filterViewID = filterId(SpreadsheetID, filterViewName); 
var url = createURL(spreadsheetURL, filterViewID); 
Logger.log(url);// Testing to see the correct url is created 
var po_numID = ss.getSheetByName("Purchase Orders List").getRange("A2").getDisplayValue().substr(0,3);
Logger.log(po_numID);
var email_va = ss.getSheetByName("Purchase Orders List");
var values = email_va.getRange("Q2:Q");
var values1 = email_va.getRange("T2:T");
Logger.log(values)
var emailDataSheet = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/17G0QohHxjuAcZzwRtQ6AUW3aMTEvLnmTPs_USGcwvDA/edit#gid=1242890521").getSheetByName("TestA"); 

Logger.log(emailDataSheet.getSheetName());


 var emailData = emailDataSheet.getRange("A2:A").getDisplayValues().flat().map(po => po.substr(0,3));
    Logger.log(emailData)

    var subject = po_numID + " Po Log Daily Notification "; 
    
    
    var options = {} 
  
    options.htmlBody = "Hi All, " + "The following" + '<a href=\"' +url+ '" > Purchase Orders </a>' + "are over 80% spent" + "";

    // I believe this if statement is the problem I am writing it in correctly 
      if(values.getDisplayValues() === "On-going" || values.getDisplayValues() === "" && values1.getDisplayValues() >= "80%"){
      
     emailData.every((po, index) => {
    if (po == po_numID){
      const email = emailDataSheet.getRange(index + 2,7).getValue();
      console.log(email);
      MailApp.sendEmail(email, subject, '', options); 
      return false;
    } else {
      return true;
    }
  });
  }  
}

https://docs.google.com/spreadsheets/d/1QW5PIGzy_NSh4MT3j_7PggxXq4XcW4dCKr4wKqIAp0E/edit#gid=611584429 Here is the spread sheet

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

values.getDisplayValues() gives you an array.

Basically it makes no sense to compare an array and a string with === and >= etc.

You need to decide which element of the array there should be. May be something like values.getDisplayValues()[0][0] (because it's likely an 2D-array). I can't check your code, so just a guess.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda