From: Xpresslearn on
Here is an example of a telnet library along with a program that uses it to log into a Cisco router and download the IOS configuration.

http://www.xpresslearn.com/networking/code/csharp-telnet-client



AlhambraEidosDesarroll wrote:

how I do telnet
13-Jan-09

hi all

how can i do using c#

telnet mail.domain.es 25

using c# code

Iwant know if i can access to telnet (smtp 25) of a domain.

thanks.

Previous Posts In This Thread:

On Tuesday, January 13, 2009 4:27 PM
AlhambraEidosDesarroll wrote:

how I do telnet
hi all

how can i do using c#

telnet mail.domain.es 25

using c# code

Iwant know if i can access to telnet (smtp 25) of a domain.

thanks.

On Tuesday, January 13, 2009 6:13 PM
anonymous wrote:

yes and no.You have built in classes for SMTP so you shouldnt have to "telnet".
yes and no.

You have built in classes for SMTP so you shouldnt have to "telnet". If you
really must telnet then yes you have full access to sockets to do that also.
I dont think you have a base .net telnet class already rolled though.


"Alhambra Eidos Desarrollo"
<AlhambraEidosDesarrollo(a)discussions.microsoft.com> wrote in message
news:5982D3A5-7A9B-4FAF-8847-C3FBC1E036FA(a)microsoft.com...

On Tuesday, January 13, 2009 6:15 PM
anonymous wrote:

FYI you didnt mention what version but im on 2.0 and have System.Net.Mail.
FYI you didnt mention what version but im on 2.0 and have
System.Net.Mail.SmtpClient available.


"Alhambra Eidos Desarrollo"

On Tuesday, January 13, 2009 6:57 PM
arn wrote:

Re: how I do telnet
Alhambra Eidos Desarrollo wrote:

TcpClient class should do fine.

Example:

public static bool TestMailServer(string server)
{
try
{
string ownhost = Dns.GetHostName();
TcpClient client = new TcpClient(server, 25);
StreamWriter wrt = new StreamWriter(client.GetStream());
wrt.WriteLine("HELO " + ownhost);
wrt.WriteLine("QUIT");
wrt.Flush();
wrt.Close();
client.Close();
return true;
}
catch
{
return false;
}
}

Arne

On Tuesday, January 13, 2009 6:59 PM
arn wrote:

Re: how I do telnet
anonymous wrote:

The email classes can only be used to actually send an email not
to just test if the SMTP server are there.

That may or may not be important.


..NET does not come with telnet, but telnet is not needed for talking
to a SMTP server. Basic socket is enough - and .NET has that - TcpClient
is most likely the easiest interface.

Arne

On Tuesday, January 13, 2009 8:28 PM
anonymous wrote:

Very crude example but you felt the need to elebrate on my response with
Very crude example but you felt the need to elebrate on my response with
garbage so here is one way to "test if the SMTP server are there" using the
SmtpClient.

static void Main(string[] args)
{
System.Net.Mail.SmtpClient smtpclient = new
System.Net.Mail.SmtpClient("192.168.0.250", 25);
try
{
smtpclient.Send("root(a)localhost", "root(a)localhost",
"subject", "body");
}
catch (Exception ex)
{
Console.WriteLine("Failure Sending\n" +
ex.InnerException.Message.ToString());
Console.Read();
return;
}

Console.WriteLine("Success");
Console.Read();

}


"Arne Vajh?j" <arne(a)vajhoej.dk> wrote in message
news:496d2abe$0$90266$14726298(a)news.sunsite.dk...

On Tuesday, January 13, 2009 8:44 PM
arn wrote:

Re: how I do telnet
anonymous wrote:

Not garbage - pure truth.


[code omitted]

That code actually sends an email.

Arne


Submitted via EggHeadCafe - Software Developer Portal of Choice
MSChart For VB.Net
http://www.eggheadcafe.com/tutorials/aspnet/45729dc8-c102-4dc6-9aa7-4f6246763650/mschart-for-vbnet.aspx