Delete THOUSANDS of unread messages in Yahoo without scrooling down

yahoo-mail

Is there a way to delete all of unread yahoo emails (>110k) without scrolling down?
It seems none of How can I select all unread messages on the new version of Yahoo Mail? works.

Best Answer

It seems the only way is doing it through coding.I confess this is not a perfect solution and am still looking for better answers. I selected C# and have to use IMAP. IMAP is a protocol for working with emails through coding. The other one is POP3 but it does not have an attribute to see if a message has been seen (read) or not (unread).

THIS DELETES YOUR UNREAD EMAILS PERMANENTLY.

1-I had to install Visual Studio and create a C# application.

2- Download MailKit by going to Tools->NuGet packet manager->Manage NuGet packages for Solution->Select MailKit and install as shown below. enter image description here

enter image description here

3- Create an app password in Yahoo for this tool (I called it IMAP just for the sake of naming) as it asks for a name. enter image description here

4- Then writing the below code in c#

        using System;
    using MailKit;
    using MailKit.Search;
    using MailKit.Net.Imap;
    using MailKit.Security;
    using System.Threading;

    namespace ConsoleApp1
    {
        class Program
        {
            static void Main(string[] args)
            {

                using (var client = new ImapClient())
                {
                    int j = 1;
                     
                     
                   l1: client.Connect("imap.mail.yahoo.com", 993, SecureSocketOptions.SslOnConnect);

                    // Note: use your real username/password here...
                    client.Authenticate("Your yahoo email address", "PP password you generated earlier in Step 3");
                    try
                    {
                        // open the Inbox folder...
                        client.Inbox.Open(FolderAccess.ReadWrite);

                        //search unread messages 
                        var uids = client.Inbox.Search(SearchQuery.NotSeen);

                        Console.WriteLine("You have {0} unread message(s).", uids.Count);
                        for (int i = 0; i < uids.Count-30; i++) //This keeps your last 30 messages (if you recive more than 30 message during the deletion process then you need to increase this)
                        {
                            var uids1 = uids[i];
                             

                            client.Inbox.AddFlags(new UniqueId[] { uids[i] }, MessageFlags.Deleted, true);
                            Console.WriteLine("You have {0} unread message(s).", uids.Count - i);
                            if (j % 500 == 0)// I think this is required as this solves the problem of being loged out by IMAP server
                            {
                                client.Disconnect(true);
                                Console.WriteLine("Diconnected");
                                Thread.Sleep(10);
                                goto l1;
                            }

                        }
                    }
                    catch (Exception e)
                    {
// sometime IMAP throw an error regarding the search query, maybe a bug, this solves it
                        client.Disconnect(true);
                        Console.WriteLine("Error");
                        goto l1;
                    }
                    j++;
                }

and the output:

enter image description here

It took me about 17 hrs to delete my unread messages