-
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;
}
}
-
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.
-
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!