Link to home
Start Free TrialLog in
Avatar of REA_ANDREW
REA_ANDREWFlag for United Kingdom of Great Britain and Northern Ireland

asked on

POP3 Authorization

Hi,

      I have been working on this code which will access a pop3 server and thus retrieve the emails. I have been working around a tutorial.  I can connect to the server,

it returns +OK

But when I supply the username and password for the account it does not allow me access. I am supplying the correct Information as I can access this email box with Outlook Express with the same username and password.

I type in the pop3 server name and use PORT 110 (POP3) <--------Everything is successful apart from the way I send the username and password.

Anyways here is my code, thank you in advance.

    protected void Button1_Click(object sender, EventArgs e)
    {
        OutPut.InnerHtml = "";
        try
        {
            TcpClient AndyTcpCLient = new TcpClient();
            AndyTcpCLient.Connect(txtServer.Text, Convert.ToInt32(DropDownList1.SelectedValue));
            NetworkStream netStream = AndyTcpCLient.GetStream();
            StreamReader strReader = new StreamReader(netStream);
            if (AndyTcpCLient.Connected)
            {
                OutPut.InnerHtml += "You have Connected <br />";
                OutPut.InnerHtml += strReader.ReadLine() + "<br />";
                byte[] WriteBuffer = new byte[256];

                ASCIIEncoding enc = new ASCIIEncoding();
                WriteBuffer = enc.GetBytes("USER xxxxxxxx \r\n");
                netStream.Write(WriteBuffer, 0, WriteBuffer.Length);
                //OutPut.InnerHtml += strReader.ReadLine()+"<br />";
                WriteBuffer = null;
                WriteBuffer = enc.GetBytes("PASS xxxxxxxx \r\n");
                netStream.Write(WriteBuffer, 0, WriteBuffer.Length);
                OutPut.InnerHtml += strReader.ReadLine() + "<br />";
                //WriteBuffer = enc.GetBytes("LIST\r\n");
                //                netStream.Write(WriteBuffer, 0, WriteBuffer.Length);
                OutPut.InnerHtml += strReader.ReadLine() + "<br />";

            }

        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }

    }
ASKER CERTIFIED SOLUTION
Avatar of eltic
eltic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of REA_ANDREW

ASKER

thanks I will try this.

This code looks challenging too, so thanks for that As i am learning C# I want to be in at the Deepend :-)  .

Will get back to you with the results. Thanks again

Andrew