Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Script is failing when trying to pull a xlsm attachment from my email daily

I have written a script to pull daily an attachment that is sent with the same description daily on a xlsm attachment into a google sheet so that it is in a more useable format for the desired audience, but the script is currently failing.

The email also has a picture embedded into the footer, which could also be cuasing part of the problem.

Script i am using is below and it is now failing at line 18

Unsure of where to go with this, thanks in advance

function importxlsmFromGmail() {

  var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("INPUT");
  ws.getRange("A1:M").clearContent();

  var threads = GmailApp.search('from:Services@customer.com subject:"Routes Delay"');
  var message = threads[0].getMessages()[0];
  var attachment = message.getAttachments()[0];
  // Is the attachment a xlsm file
  attachment.setContentTypeFromExtension();
  
  Logger.log(attachment.getContentType())
  if (attachment.getContentType() === "application/vnd.ms-excel.sheet.macroenabled.12") {
  attachment.setContentType(MimeType.MICROSOFT_EXCEL);
}{

    var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("INPUT");
    var xlsmData = Utilities.parsexlsm(attachment.getDataAsString(), ",");  // Error occurs here

    // Remember to clear the content of the sheet before importing new data
    //sheet.clearContents().clearFormats();
    sheet.getRange(1, 1, xlsmData.length, csvData[0].length).setValues(xlsmData);
    var total_lenght = sheet.getRange("A1:A").getValues();
    var last_row = total_lenght.filter(String).length;
    //console.log(Alast)
    // var cell = sheet.getRange("F2:F" & last_row);
    // cell.setNumberFormat("0.0");

  }
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda