Open pony-bliberatore opened 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?
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:
`/*
/**
@param {function} callback */ function eachMessage(query, limit, callback) { if (typeof query == 'function') { callback = query; query = null; limit = null; } if (typeof limit == 'function') { callback = limit; limit = null; } if (typeof callback != 'function') { throw "No callback provided"; } limit = parseInt(limit) || 10; query = query || 'in:inbox';
var threads = GmailApp.search(query, 0, limit); for (var t=0; t < threads.length; t++) { var messages = threads[t].getMessages(); for (var m=0; m < messages.length; m++) { callback(messages[m]); } } }
/**
@param {function} callback */ function processStarred(query, limit, callback) { if (typeof query == 'function') { callback = query; query = null; limit = null; } if (typeof limit == 'function') { callback = limit; limit = null; } if (typeof callback != 'function') { throw "No callback provided"; } query = (query ? query + ' AND ' : '') + 'is:starred';
eachMessage(query, limit, function(message) { message.isStarred() && !message.isInTrash() && callback(message) && message.unstar(); }); }
/**
@param {function} callback */ function processUnread(query, limit, callback) { if (typeof query == 'function') { callback = query; query = null; limit = null; } if (typeof limit == 'function') { callback = limit; limit = null; } if (typeof callback != 'function') { throw "No callback provided"; } query = (query ? query + ' AND ' : '') + 'is:unread';
eachMessage(query, limit, function(message) { message.isUnread() && !message.isInTrash() && callback(message) && message.markRead(); }); }
/**
/**
/**
/**
@return {Blob} */ function messageToHtml(messages, opts) { opts = opts || {}; defaults_(opts, { includeHeader: true, includeAttachments: true, embedAttachments: true, embedRemoteImages: true, embedInlineImages: true, embedAvatar: true, width: 700, filename: null });
if (!(messages instanceof Array)) { messages = isa(messages, 'GmailThread') ? messages.getMessages() : [messages]; } if (!messages.every(function(obj){ return isa(obj, 'GmailMessage'); })) { throw "Argument must be of type GmailMessage or GmailThread."; } var name = opts.filename || sanitizeFilename_(messages[messages.length-1].getSubject()) + '.html'; var html = '\n' + '\n' + '
\n';for (var m=0; m < messages.length; m++) { var message = messages[m], subject = message.getSubject(), avatar = null, date = formatDate(message), from = formatEmails(message.getFrom()), to = formatEmails(message.getTo()), cc = formatEmails(message.getCc()), bcc = formatEmails(message.getBcc()), body = message.getBody();
if (opts.includeHeader) { if (opts.embedAvatar && (avatar = emailGetAvatar(from))) { avatar = '
'; } else { avatar = ''; } html += ' \n'; if (opts.embedRemoteImages) { body = embedHtmlImages(body); } if (opts.embedInlineImages) { body = embedInlineImages(body, message.getRawContent()); } if (opts.includeAttachments) { var attachments = message.getAttachments(); if (attachments.length > 0) { body += '@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.
Ah, thanks -- done.
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 :-)
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:
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:
You are right ! My bad. There is a merge request, but @pixelcog still has to merge it in the main repo !
Trying your sample code. Added both libraries, and then added this code.
function saveExpenses() { GmailUtils.processStarred('label:Accounting_PDF', 5, function(message) {
}); }
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.