C# – error using c#mail.dll


I'm trying to read through a gmail account to get gps data that is being sent there ( in the text of a email) from an moble phone (my phone)

using (Pop3Client cl = new Pop3Client())
                cl.UserName = "crash893";
                cl.Password = "password";
                cl.ServerName = "pop.gmail.com";
                cl.AuthenticateMode = Pop3AuthenticateMode.Pop;
                cl.Ssl = true;
                ///Get first mail of my mailbox
                Pop3Message mg = cl.GetMessage(1);  <<<<<<<<<< ERROR
                String MyText = mg.BodyText;
                ///If the message have one attachment
                Pop3Content ct = mg.Contents[0];
                ///you can save it to local disk

but I get a exception on the "get first mail of mailbox message

"Higuchi.Net.Pop3.Pop3ConnectException: Pop3 connection is closed
at Higuchi.Net.Pop3.Pop3Client.SendCommand(String inCommand)
at Higuchi.Net.Pop3.Pop3Client.Execute(String inCommand, Boolean inIsMultiLine)
at Higuchi.Net.Pop3.Pop3Client.Execute(Pop3Command inCommand)
at Higuchi.Net.Pop3.Pop3Client.GetMessage(Int64 inMailIndex)"}

Ideally what i would like to do is open this read all the new unread emails in this account for a certain subject line then read the data in the body and mark them as read

does anyone know why its erroring out

does anyone have any experince with c#mail that hey could point me in the right direction for reading and makring emails as read etc

Best Solution

It is not possible to mark emails as read using the POP protocol.

Try using IMAP.

Related Question