jLynx
jLynx

Reputation: 1149

Move email to trash POP3 using MailKit

How would I move an email to the trash or delete it when connecting with POP3.

            using (var client = new Pop3Client())
            {
                client.Connect("pop-mail.outlook.com", 995, true);
                client.AuthenticationMechanisms.Remove("XOAUTH2");

                client.Authenticate("username", "password");
                int count = client.GetMessageCount();
                for (int i = 0; i < count; i++)
                {
                    var message = client.GetMessage(i);
                    if (message.Subject.Contains("MySubject"))
                    {
                        MessageBox.Show("To: " + message.To[0].ToString());
                        //Delete email here
                    }
                }

                client.Disconnect(true);
            }

I can only find how to do it with IMAP but I need to use POP

Upvotes: 0

Views: 2148

Answers (2)

sameerkn
sameerkn

Reputation: 2259

In POP Protocol, one can sync/access/operate only Inbox Folder.

In POP Protocol, one can only DELETE mails but cannot move the mails from one folder to another. If the POP server provides some custom functionality like: "when a mail is deleted then the mail will be copied to Trash" then you can automatically achieve the behavior of deleted mails getting moved to Trash Folder.

In POP Protocol, there is only DELE n command for deleting a mail with sequence number n.

Upvotes: 0

Related Questions