Delete THOUSANDS of unread messages in Yahoo without scrooling down


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;
namespace ConsoleApp1
{
    class Program
    {
       static void Main(string() args)
       {
            using (var client = new ImapClient())
            {
           
                client.Connect("imap.mail.yahoo.com", 993, SecureSocketOptions.SslOnConnect);

          
                client.Authenticate("Your yahoo email address", "APP password you generated earlier in Step 3");

            // open the Inbox folder...
                client.Inbox.Open(FolderAccess.ReadWrite);

            // search the Unread messages)
                var uids = client.Inbox.Search(SearchQuery.NotSeen);
            
            //shows the total number of unread messages
                Console.WriteLine("You have {0} unread message(s).", uids.Count);
            
            //starts the deleting process from the most recent ones so you can check your Yahoo mail box to see how it works
                for (int i= uids.Count-1; i>0;i--)
                {
                var uids1 = uids(i);
              
                client.Inbox.AddFlags(new UniqueId() { uids(i) }, MessageFlags.Deleted,true);
                Console.WriteLine("You have {0} unread message(s).", i);

                }
                client.Disconnect(true);
           }
        }
     }
  }

and the output:

enter image description here