Spire.Email for .NET is a professional .NET Email library specially designed for developers to create, read and manipulate emails from any .NET (C#, VB.NET, ASP.NET) platform with fast and high quality performance.

Wed Aug 25, 2021 12:56 pm

Hi. How do I delete or archive emails which have been read? The other question on this forum were asked before v.4.7 came out. Thank you.

Jonathan99
 
Posts: 6
Joined: Wed Aug 18, 2021 4:51 pm

Thu Aug 26, 2021 10:09 am

Hello,

Thank you for your inquiry.
Please refer to the following code to archive and delete emails. If there is any question, please feel free to write back.
Code: Select all
            ImapClient imap = new ImapClient();
            imap.Host = "outlook.office365.com";
            imap.Port = 143;
            imap.Username = "x@y";
            imap.Password = "password";
            imap.ConnectionProtocols = ConnectionProtocols.Ssl;
            imap.Connect();                       
            imap.Select("inbox");
            //Find all read messages
            ImapMessageCollection imapMessage = imap.Search("'Seen' = 'true'");
            foreach (ImapMessage message1 in imapMessage)
            {
                //Copy mail to archive folder
                imap.Copy(message1.SequenceNumber, "archive");
                //Mark the message as deleted
                imap.MarkAsDeleted(message1.SequenceNumber);
            }
            //Delete all flagged messages
            imap.DeleteMarkedMessages();

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Aug 26, 2021 1:51 pm

Thanks again, Annika.

Jonathan99
 
Posts: 6
Joined: Wed Aug 18, 2021 4:51 pm

Fri Aug 27, 2021 10:50 am

Hello,

You're welcome.
If you have other questions about using Spire.Email in the future, please feel free to contact us.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Email