title: Add multiple dynamic attachments to email
body: <p>I'm listing all PDF files of a folder and send them into an email.
  The issue is that I don't know how attach multiple files.</p>
  
  <p>This is what I've tried so far: put files into blob then pass it.
  Other try was to put blob[0] and blob<a href="https://i.stack.imgur.com/ehR9r.png" rel="nofollow noreferrer">1</a> if there is 2 pdf files but it doesn't work.</p>
  
  <pre><code>var folders = DriveApp.getFoldersByName(folderToScan);
    var folder = folders.next();
    var contents = folder.getFiles();
  
    var blob = [];
    var filesTextList = "";
  
    // foreach file
    for(var counter = 0;contents.hasNext();counter++)
    {
      file = contents.next();
  
      var MimeType = file.getMimeType();
  
      // filter PDF
      if(file.getMimeType() == "application/pdf")
         {
           blob[counter] = file.getBlob();
           // add file name to text
           filesTextList += "\n" + file.getName();
      }
    }
  
    MailApp.sendEmail(sender, subject, message, 
     {attachments: blob}
  );
  </code></pre>
  
  <p>If I only have 1 blob file, {attachments: blob[0]} is working but it's not dynamic</p>
  
  <p>Here is the debugger at the line of the mail:
  <a href="https://i.stack.imgur.com/ehR9r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ehR9r.png" alt="debugger"></a></p>