How to find most unread email recipient and delete all those emails
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I want a way, possibly with a little script, to find the recipient on my gmail inbox that has the highest amount of unread emails. And also how to delete them all forever, that his: make that recipient emails always deleted.

are you language specific or any language as long as its a working solution?
mashtullah 8 months ago
Ideally you would use the gmail api:
remotemass 8 months ago
I have just used Javascript on and it has worked well.
mashtullah 8 months ago
Hi Mashtullah! Please give me this extra help:
remotemass 8 months ago
Hi @remotemass, yes i have got you, i just have a kind request. on the solution page when you scroll down you can comment and i will immediately get an alert and work on it, now or even after the bounty, thats the beauty of github and both of us will have proper documentation in case years later you want to remember how this tool came to work as it does, then you can always scroll down our conversation on the code page!
mashtullah 8 months ago
awarded to mashtullah

Crowdsource coding tasks.

1 Solution

This can be done by creating a script to be doing the following steps to achieve your solution.
1.Search your inbox for all unread emails
2.For each email we get the sender's email address and add it to the array emailArray
3.From our array we can get the email that has the most emails.
4.Search your inbox again, now specifically for unread emails from that email we found on step 3...
5.Move all the emails found to the trash(Google will automatically delete anything in trash after 30 days...)
Here is the working solution and i have tested it on my gmail account.

To test this first Empty your trash folder(so that you can see the results after running the script

Now go to and create a new project. You can either copy all the code above and paste on your new project or download the file and import the file in your project.
Then click Run > Run Function > trashEmails then wait like a minute or two for the script to run(i had 230 emails deleted from one sender,it took 142 seconds to run on my inbox, how fast this script runs depends on how big your inbox is..).
After the script runs go check your trash folder.

I have updated my solution to handle your help request.
mashtullah 8 months ago