Results 1 to 3 of 3

Thread: C# Pop3?

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Question C# Pop3?

    Hey all,

    i need to implement a small c# POP3 Service for one of my customers.

    I found some sample code on the net for this, but it does not seem to work! Could anyone try it to see if its just my Company Firewall blocking everything, or if theres something wrong with my code.

    Thanks,

    Stephan

    Code:
    public bool connectToServer(string server, string username, string password)
        {
        	private TcpClient myClient;
    		private static int port = 110;
            bool result = true;
            
            try
            {
                string message ="";
                myClient = new TcpClient();
                myClient.Connect(server,port);  
                //check if connection is succesfull
                if(getResponse().Substring(0,3) != "+OK")
                {
                    result = false;
                }
    
                //send username to server
                message = "USER " + username + "\r\n";
                writeMessage(message);
                //check if server recognised the username
                if(getResponse().Substring(0,3) != "+OK")
                {
                    result = false;
                }
                //send password to server
                message = "PASS " + password + "\r\n";
                writeMessage(message);
                //check if server recognised the password
                if (getResponse().Substring(0,3)!= "+OK")
                {
                    result = false;
                }
                return result;
            }
            catch(Exception ex)
            {
                result = false;
                return result;
            }
        }
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  2. #2
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    are you getting some kind of error? I see writemessage but I do not see how it would send to the server being that your tcpclient object is declared inside the method without you passing reference.

  3. #3

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Actually I get the message that the server is not responding in time or in a proper way! (Something like that!)

    Its not even getting to the write Method yet, the error happens inside the myClient.Connect method!

    Thats why I figure it might be a Firewall Problem (Ports being closed)!

    I would try myselfe but I just moved and dont have Internet at home at the moment!
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width