I receive large numbers of messages daily from an automated system, and I've just discovered that many of them have been marked as spam. I now have ~16,000 non-spam messages in my Gmail spam folder, and I'd like them to be marked as "not spam". This shouldn't be that hard, because all of the messages I want to save have a Gmail label ("Feedback") applied to them by a filter, so simply searching in:spam label:feedback returns all the messages I want to save. So far so good.

The problem is that while the "Not spam" button works for selecting a small number of messages, or even all 50 messages on the page, it disappears entirely once you click the "Select all conversations that match this search" link to select all 16,000 conversations on all pages. Obviously, at this volume, doing 50 at a time isn't feasible. What can I do here?

  • 2
    you can cut this task in half by setting your preferences to show 100 conversations. To prevent the list from growing you can also modify the filter that adds the label to never send to spam. Jul 18, 2015 at 12:02

2 Answers 2


I found an easier solution that doesn't require Apps Script: While the GMail UI removes the "Not spam" button after clicking "Select all conversations that match this search", it leaves a "Move to Inbox" button, and using that automatically removes the Spam pseudo-label. Combining this with a temporary label just for these messages, I was able to move them from Spam to Inbox to Archive.


You can do this with a script. I tested it by labeling a few messages in my spam folder and executing it. (I don't have 16000 messages to test on...)

function removeFromSpam() {
  while (true) {
    var threads = GmailApp.search("in:spam label:feedback", 0, 50);
    if (threads.length>0) {
    else {

The script picks the first 50 spam threads with the label, and moves them to Archive. Then the process repeats. This is done in a loop because Script documentation warns against trying to get too much from the search method at once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.