/mail/community?hl=en
This content is likely not relevant anymore. Try searching or browse recent questions.
-
deleting millions of messages 0 Recommended Answers 26 Replies 156 Upvotes
1 Recommended Answer
$0 Recommended Answers
1 Relevant Answer
$0 Relevant Answers
I have over 1.5 million emails in my sent box and another 50,000 in my inbox. I am trying to delete 
these before setting up a new mail app on Mac OS. Reason being is I don't need these and it will want to sync them. I click the select all then go to the middle and click select all Select all 1,495,107 conversations in Inbox and then try to delete and nothing is happening.
Most Relevant Answer Most Relevant Answers (0)
All Replies (26)
Most Relevant Answer
Delete multiple messages
  1. On your computer, go to Gmail.
  2. Check the boxes to the left of the messages.
  3. At the top, click Delete .
Delete all messages in a category
  1. On your computer, go to Gmail.
  2. In the top left, check the box to select all messages. If you have over one page of messages, click Select all conversations.
  3. At the top, click Delete.
marked this as an answer
Most relevant based on info available
-
Most Relevant Answer
I am doing this from the Chrome browser. I keep selecting all and 
then a message box appears

Confirm bulk action
This action will affect all 1,489,433 conversations in Inbox. Are you sure you want to continue?

I confirm it and nothing happens. Or I get this

Oops, something went wrong
Recent changes may not have been saved.
marked this as an answer
Most relevant based on info available
Most Relevant Answer
Check in incognito mode.
marked this as an answer
Most relevant based on info available
-
Most Relevant Answer
What does incognito mode do for deleting messages?
marked this as an answer
Most relevant based on info available
Most Relevant Answer
Chrome won't save your browsing history, cookies and site data, or information entered in forms.
marked this as an answer
Most relevant based on info available
Most Relevant Answer
Read the help article above.
marked this as an answer
Most relevant based on info available
Most Relevant Answer
Honestly you should no give advice if you have no idea what you are talking about. Browser history, cookies, nor site data will have any effect one way or the other on a server side process of deleting millions of emails. Suggesting incognito is ridiculous advice that will not stop google from timing out when trying to delete that many messages.
marked this as an answer
Most relevant based on info available
Most Relevant Answer
The proper way for people coming in the future is as follows:

You go to https://script.google.com

You paste the following code:

function batchDeleteA() {
var batchSize = 100 // Process up to 100 threads at once
var threads = GmailApp.search('label:inbox older_than:2d');
for (j = 0; j < threads.length; j+=batchSize) {
GmailApp.moveThreadsToTrash(threads.slice(j, j+batchSize));
}
}

You save the project.

Then you click "run" » "run function" » batchDeleteA()

It will say i requires access to gmail. You grant access. It will tell you your script is unsafe and make you click "advanced" and "do his anyways". 

Then you let it run. Note it make take a few days to delete them all. It is not instant.
marked this as an answer
Most relevant based on info available
Most Relevant Answer
Thanks for the info Bruce
marked this as an answer
Most relevant based on info available
Most Relevant Answer
I can't find any documentation stating this, but it appears that GmailApp.search returns only 500 threads.

There are some other limits listed here: https://developers.google.com/apps-script/guides/services/quotas

I'm in a G Suite Business account, so my Apps Script function will only run for 30 minutes before timing out. And I can move only 50,000 emails to trash per day.

I've set my function to wrap the search in a loop. And I've set a trigger to run the function once per hour. I figure 30 minutes of deleting emails followed by 30 minutes of rest will allow Google's Gmail servers some time to catch up if they need to.

The 50,000 emails per day limit is annoying, though. It'll take 20 days to delete 1,000,000 emails, and I've got more than that.

function deleteOldEmail() {
  var batchSize = 100
  while (true) {
    var threads = GmailApp.search('before:2018/10/12');
    for (j = 0; j < threads.length; j+=batchSize) {
      GmailApp.moveThreadsToTrash(threads.slice(j, j+batchSize));
    }
  }
}
marked this as an answer
Most relevant based on info available
This question is locked and replying has been disabled.
Discard post? You will lose what you have written so far.
Write a reply
10 characters required
Failed to attach file, click here to try again.
Discard post?
You will lose what you have written so far.
Personal information found

We found the following personal information in your message:

This information will be visible to anyone who visits or subscribes to notifications for this post. Are you sure you want to continue?

A problem occurred. Please try again.
Create Reply
Edit Reply
Delete post?
This will remove the reply from the Answers section.
Notifications are off
Your notifications are currently off and you won't receive subscription updates. To turn them on, go to Notifications preferences on your Profile page.
Report abuse
Google takes abuse of its services very seriously. We're committed to dealing with such abuse according to the laws in your country of residence. When you submit a report, we'll investigate it and take the appropriate action. We'll get back to you only if we require additional details or have more information to share.

Go to the Legal Help page to request content changes for legal reasons.

Reported post for abuse
Unable to send report.
Report post
What type of post are you reporting?
Google takes abuse of its services very seriously. We're committed to dealing with such abuse according to the laws in your country of residence. When you submit a report, we'll investigate it and take the appropriate action. We'll get back to you only if we require additional details or have more information to share.

Go to the Legal Help page to request content changes for legal reasons.

Reported post for abuse
Unable to send report.
This reply is no longer available.
/mail/threads
//accounts.google.com/ServiceLogin
You'll receive email notifications for new posts at
Unable to delete question.
Unable to update vote.
Unable to update subscription.
You have been unsubscribed
Deleted
Unable to delete reply.
Removed from Answers
Marked as Recommended Answer
Removed recommendation
Undo
Unable to update reply.
Unable to update vote.
Thank you. Your response was recorded.
Unable to undo vote.
Thank you. This reply will now display in the answers section.
Link copied
Locked
Unlocked
Unable to lock
Unable to unlock
Pinned
Unpinned
Unable to pin
Unable to unpin
Marked
Unmarked
Unable to mark
Reported as off topic
/mail/profile/0?hl=en