fleapower
fleapower

Reputation: 65

Gmail script for creating and deleting labels not working

I have had a script running on a daily trigger for several years which manipulates Gmail labels in order to provide snooze functionality. I have not modified the code. As of 01MAY, it has not been working. Specifically, neither deleteLabel() nor createLabel() will work. The rest of the function works (e.g., the emails are moved from the label into the inbox).

One thing which makes me think this is something Google has caused is that the variable "today" label is removed from the individual emails when they are moved to the inbox. This shouldn't happen unless something is occurring within the deleteLabel method.

function UnSnoozeToday() {
    GmailApp.createLabel(today); // creates the label in case it doesn't exist
    today = GmailApp.getUserLabelByName(today);
    var page = null;
    while(!page || page.length == 500) {
        page = today.getThreads(0,500);
        if (page.length > 0) {
            GmailApp.moveThreadsToInbox(page);
        }
    }
    today.deleteLabel();
}

Upvotes: 0

Views: 254

Answers (1)

fleapower
fleapower

Reputation: 65

I discovered something this morning. The created/deleted folders are reflected correctly in both Gmail for Android and the basic HTML version of Gmail. So this means the script is working and the problem is with Gmail's web interface...perhaps some kind of caching or prefetch which is storing the label list. Guess I'll just have to wait for Google to fix it.

Upvotes: 1

Related Questions