Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
¿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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!