Delete Email

May 20, 2009 at 6:55 PM

How do I delete an email from the pop3 server?

Coordinator
May 21, 2009 at 10:59 PM

using (Pop3Client cl = new Pop3Client())
{
    cl.UserName = "MyUserName";
    cl.Password = "MyPassword";
    cl.ServerName = "MyServer";
    cl.AuthenticateMode = Pop3AuthenticateMode.Pop;
    cl.Authenticate();
    ///Delete first mail of my mailbox    
    cl.DeleteEMail(1);
}

May 22, 2009 at 1:24 PM

That is what I'm trying to do and I can read the emails, but when I call the DeleteEMail method, the messages are still in my inbox on the server.

Any ideas?

Coordinator
May 22, 2009 at 3:12 PM
Edited May 22, 2009 at 3:14 PM

Oh,I have one mistake.

The DeleteEMail method request a command text as "DELE 1" under the food.

Mail server receive this request and set a delete flag to the message.

And you must call Quit method.

Mail server receive quit request and delete all mail set as delete.

This proces is defined by specification of pop3 protocol

You write code like below...

using (Pop3Client cl = new Pop3Client())
{
    cl.UserName = "MyUserName";
    cl.Password = "MyPassword";
    cl.ServerName = "MyServer";
    cl.AuthenticateMode = Pop3AuthenticateMode.Pop;
    cl.Authenticate();
    ///Delete first mail of my mailbox    
    cl.DeleteEMail(1);
    ///Delete all mail from mailbox set as delete
    cl.Quit();

}

But what I wonder is that the Quit method is called inside dispose method.

If you copy all above code,these messages must be deleted.

If not,please add Quit method after call DeleteEMail method.

Please try.

 

 

May 22, 2009 at 3:56 PM

Thanks, calling Quit worked.  The syntax for it was:

using (Pop3Client cl = new Pop3Client("username", "password", "server"))
{
    cl.Authenticate();

    cl.DeleteEMail(1);

    cl.
ExecuteQuit();
}

There is no "Quit" method, you have to call "ExecuteQuit".

Thanks again.

Coordinator
May 22, 2009 at 4:21 PM

That's right ExecuteQuit !!

regard