Sorry, i'm not a programmer,
I'm using this gmail app script (CLEANINBOX) and it works great in roder to keep my inbox clean. As I need to use INBOX app (mobile) and GMAIL app (desktop) at the same time I need to implement this script in order to avoid that PINNED messages in INBOX get archieved.
I inserted a condition in the IF sequence and it does not work After struggling a bit I realized (correct me if I'm wrong) that the following code is not working becouse !thread.getLabels()=='PINNED') IS NOT BOOLEAN
Can anybody point me to the correct code?
function cleanInbox() {
var threads = GmailApp.getInboxThreads();
for (var i = 0; i < threads.length; i++) {
var thread=threads[i];
if (!thread.hasStarredMessages() && !thread.isUnread() && !thread.getLabels()=='PINNED') {
GmailApp.moveThreadToArchive(threads[i]);
}
}
}
The statement
!thread.getLabels()=='PINNED'is boolean (as the operand == outputs true or false). I think your problem is thatthread.getLabels()does not return a string and therefore it will never be equal to'PINNED'EDIT:
The
getLabels()method return value is GmailLabel[]. You can iterate over the labels and check your condition by adding this code: