pixelcog / gmail-to-pdf

A Google Apps Script library for converting Gmail messages to PDFs for easy archival.
http://bit.ly/1CsBl8U
123 stars 38 forks source link

SyntaxError: Unexpected token class (line 421, file "Code", project "GmailUtils") #14

Open pony-bliberatore opened 4 years ago

pony-bliberatore commented 4 years ago

Trying your sample code. Added both libraries, and then added this code.

function saveExpenses() { GmailUtils.processStarred('label:Accounting_PDF', 5, function(message) {

// create a pdf of the message
var pdf = GmailUtils.messageToPdf(message);

// prefix the pdf filename with a date string
pdf.setName(GmailUtils.formatDate(message, 'yyyyMMdd - ') + pdf.getName());

// save the converted file to the 'Expenses' folder within Google Drive
DriveUtils.getFolder('Accounting_PDF').createFile(pdf);

// signal that we are done with this email and it will be marked as read
return true;

}); }

Upon run, I receive this error: SyntaxError: Unexpected token class (line 421, file "Code", project "GmailUtils")

Using version 4 of the GmailUtils and version 1 of the DriveUtils.

luther-cloudbase commented 4 years ago

I see a similar error if I turn on the new apps script runtime in GAS: "Future executions of this project will run with Apps Script V8. Disable anytime via the Run menu." Solved by turning that off, but I think long term we need to resolve the issue. Does anyone know how to solve it?

lex3001 commented 4 years ago

I can't see how to create a branch to contribute here, but below is my updated code with two fixes for Apps Script V8:

GmailUtils.gs.zip

`/*

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

/**

function gettz_() { var d = new Date(); // now, or the specific date in question var s = d.toLocaleString("en", {timeZoneName: "short"}).split(' ').pop(); //Logger.log(s); return s; }

/**

/**

jmlag commented 4 years ago

@lex3001 What you have to do is: Fork this repo, commit the changes to your forked repo, then click the "New pull request" button on your forked repo's page.

lex3001 commented 4 years ago

Ah, thanks -- done.

emmanueljarri commented 3 years ago

Thank you ! It works. I saw you forked, but it looks like it's the original file in YOUR repo, not this one that you modified. To help everyone else looking for this, you could update your repo with YOUR file, and then do a pull request for it to be integrated in this repo as well :-)

lex3001 commented 3 years ago

Thank you ! It works. I saw you forked, but it looks like it's the original file in YOUR repo, not this one that you modified. To help everyone else looking for this, you could update your repo with YOUR file, and then do a pull request for it to be integrated in this repo as well :-)

Sorry if I misunderstood or if my operational knowledge of git is not up to par, but it seems the changes I made are in fact updating the existing repo AFAIK: image

emmanueljarri commented 3 years ago

Thank you ! It works. I saw you forked, but it looks like it's the original file in YOUR repo, not this one that you modified. To help everyone else looking for this, you could update your repo with YOUR file, and then do a pull request for it to be integrated in this repo as well :-)

Sorry if I misunderstood or if my operational knowledge of git is not up to par, but it seems the changes I made are in fact updating the existing repo AFAIK: image

You are right ! My bad. There is a merge request, but @pixelcog still has to merge it in the main repo !