1. var txt = msgs[i].getBody();
  2. /* We need two blob conversions - one from text to HTML and the other from HTML to PDF */
  3. var blob = Utilities.newBlob(txt, 'text/html',"Test PDF");
  4. Logger.log(txt);
  5. var tempDoc = DocsList.createFile(blob);
  6. var pdf = tempDoc.getAs('application/pdf');
  7. pdf.setName('Email As PDF');
  8. DocsList.createFile(pdf);