Reputation: 168
I made the following algorithm in Google Script which deletes all mails from a specific adress from all folders:
function deleteForever() {
var labelName
labelName="some_mail_address"
var threads = GmailApp.search("in: all from:" + labelName);
for (var i = 0; i < threads.length; i++) {
Gmail.Users.Messages.remove("me", threads[i].getId());
}
}
Is this safe to use for my gmail account? (With a trigger such that it runs every minute)
In particular, I am wondering whether a thread can contain multiple mails, and whether this can result in deleting mails which are not from the unwanted sender.
Also, I have seen "in: anywhere" on some webpages. Is this different from "in: all"?
Upvotes: 1
Views: 292
Reputation: 38373
Short answer: No.
It's not "safe" because:
the thread id is the same id for the first thread message but the first message might be from other sender.
the message will be deleted permanently
running a script every minute might consume the daily quota so you might first getting error messages and lately the trigger might be disabled due to having so many errors.
in:anywhere
is not the same as in:all
. The first will return threads labeled as spam and trash but the later doesn't.
Related
Upvotes: 3