Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialIris Simmoms
2,402 PointsHow to create a script or code to pull labelled email in gmail to drop box.
I get this error: ReferenceError: "DocsList" is not defined. (line 13, file "Code")
function send_Gmail_as_PDF() {
var gLabel = "send_gmail_as_PDF";
var thread = GmailApp.search("label:" + gLabel);
for (var x = 0; x < thread.length; x++) {
var messages = thread[x].getMessages();
for (var y = 0; y < messages.length; y++) {
var attach = messages[y].getAttachments();
var body = messages[y].getBody();
// Create an HTML File from the Message Body
var bodydochtml = DocsList.createFile('body.html', body, "text/html") /***ERROR ON LINE 13 ***/
var bodyId = bodydochtml.getId()
// Convert the HTML to PDF
var bodydocpdf = bodydochtml.getAs('application/pdf').getBytes();
var body_to_send = {
fileName: 'body.pdf',
content: bodydocpdf,
mimeType: 'application/pdf'
};
var attachmentList = [];
attachmentList.push(body_to_send);
// Trash the temporary file
bodydochtml.setTrashed(true);