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

175
Views
How to attach a calculated CSV with MailApp in Google Apps Script
  • I have a matrix array with some values that I need to parse to a CSV file.

  • I have the following code:

    let array = [["name1", 2, 3], ["name2", 4, 5], ["name3", 6, 7], ["name4", 8, 9], ["name5", 10, 11]];
    let lineArray = []
    array.forEach((fila, index) => {
         let filaComas = fila.join(',')
         lineArray.push(
            index == 0 ? "data:text/csv;charset=utf-8," + filaComas: filaComas
         )
     })
     
    let csvContent = lineArray.join("\n");

The result is a string like data:text/csv;charset=utf-8,name1,2,3\nname2,4,5\nname3,6,7\nname4,8,9\nname5,10,11, then I need to send an email with MailApp of Google Apps Script that has this 'CSV' as an attachment for download.

How can I do this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Attach CSV File

Just add this to your code:

    let file = DriveApp.createFile('filename',csvContent);
    MailApp.sendEmail('recipient','subject','body',{attachments:[file]});
  • MailApp

  • createFile

about 4 years ago · Juan Pablo Isaza Report
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!