title: Google Apps Script: read text from a .txt file
body: <p>After taking a look at the provided <a href="https://developers.google.com/apps-script/articles/sending_emails" rel="noreferrer">tutorial</a> for sending emails from a spreadsheet with Google Apps Script, I modified the given code with aims to be able to send the set of emails out with attachments as well.</p>
  
  <p>It works well enough, even with a couple quirks from the limitations of Google Apps Script (the files have to be in the Google Drive, and all files in the Google Drive with whichever name is appropriate are taken from all folders in the drive).</p>
  
  <pre class="lang-js prettyprint-override"><code>function sendEmails() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var startRow = 2;  // First row of data to process
    var numRows = 1;   // Number of rows to process
    // Fetch the range of cells A2:C3
    var dataRange = sheet.getRange(startRow, 1, numRows, 3)
    // Fetch values for each row in the Range.
    var data = dataRange.getValues();
    for (i in data) {
      var row = data[i];
      var emailAddress = row[0];  // First column
      var message = row[1];       // Second column
      var attachment = row[2];    // File name provided.
      var subject = "Mass Email";
      var files = DriveApp.getFilesByName(attachment); // Get all files with name.
      var blobs = []; // Array for attachment.
      // Move files into blobs
      while (files.hasNext()) {
        var file = files.next();
        blobs.push(file.getAs(MimeType.PLAIN_TEXT));
      }
      MailApp.sendEmail(emailAddress, subject, message, {
        attachments: blobs, // add attachments
        cc: "extra@email.com" // CC to employer
      });
    }
  }
  </code></pre>
  
  <p>After I first used it, however, I learned that I need to send the files not as attachments, but as the message body of the emails, among some other changes (this is for work). That is, I will only ever email one 'attachment' at a time to each email, and instead of that file being an attachment, its content should be copied over to the message of the email. The attachments are currently text files, and I'd like them to stay that way, but it isn't the most vital thing.</p>
  
  <p>I cannot determine a way to do this with Google Apps Script. Is this possible, or will I have to have a different way of emailing these files? (Hopefully not by hand.)</p>
  
  <p>Thanks in advance.</p>