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

342
Visualizações
¿Cómo publico un archivo de imagen con axios en Google Apps Script y lo adjunto a un correo electrónico y una fila de Google Sheet?

Tengo un formulario html simple en React que publico en mi script de Google. Hasta ahora lo tengo funcionando con texto simple (como nombre, correo electrónico) y envío un correo electrónico y creo una fila en las hojas de Google con los datos de mi formulario.

Pero, ¿cómo publico un archivo de imagen con axios de mi formulario en el script de aplicaciones, lo adjunto a un correo electrónico y lo agrego en una fila en mi hoja?

js:

 handleSubmit(e) { e.preventDefault(); var form = document.querySelector("form"); var data = new URLSearchParams(new FormData(form)).toString(); console.log(data); axios .post( "https://script.google.com/macros/s/[myscripthere]/exec", data ) .then(function (response) { console.log(response); }); }

Guión de aplicaciones:

 var TO_ADDRESS = "myemail@gmail.com"; function doPost(e) { try { Logger.log(e); var mailData = e.parameters; data record_data(e); MailApp.sendEmail({ to: TO_ADDRESS, subject: "subject text", replyTo: String(mailData.email), htmlBody: formatMailBody(mailData), }); return ContentService .createTextOutput(JSON.stringify({"result":"success","data": JSON.stringify(e.parameters) })) .setMimeType(ContentService.MimeType.JSON); } catch(error) { Logger.log(error); return ContentService .createTextOutput(JSON.stringify({"result":"error", "message": "Sorry, there is an issue with the server."})) .setMimeType(ContentService.MimeType.JSON); } } function record_data(e) { Logger.log(JSON.stringify(e)); try { var doc = SpreadsheetApp.getActiveSpreadsheet(); var sheetName = e.parameters.formGoogleSheetName || "responses"; var sheet = doc.getSheetByName(sheetName); // select the responses sheet var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]; var nextRow = sheet.getLastRow()+1; // get next row var row = [ new Date().toUTCString() ]; // first element in the row should always be a timestamp // loop through the header columns for (var i = 1; i < headers.length; i++) { // start at 1 to avoid Timestamp column if(headers[i].length > 0) { row.push(e.parameter[headers[i]]); // add data to row } } // more efficient to set values as [][] array than individually sheet.getRange(nextRow, 1, 1, row.length).setValues([row]); } catch(error) { Logger.log(error); Logger.log(e); throw error; } finally { return; } }
about 4 years ago · Juan Pablo Isaza
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