|
-
Nov 8th, 2004, 11:52 AM
#1
Thread Starter
Hyperactive Member
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
-
Nov 11th, 2004, 01:40 PM
#2
Addicted Member
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.
-
Nov 11th, 2004, 02:57 PM
#3
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|