SMTPClient.Send fails

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have written a very simple console application to send an email but it
always fails.

My computer (BN002) is running XP SP2 and has the default SMTP server
running in IIS. It is connected via static IP through Comcast commercail
services. I have disabled the firewall as well. I have written many email
programs in both CDONTS and CDOSYS and have never had any problems at all.

The code is below, followed by the error message I receive when I run it at
the command prompt.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net.Mail;

namespace ConsoleApplication2
{
class Program
{
static void Main()
{
MailAddress from = new MailAddress(@"(e-mail address removed)");
MailAddress to = new MailAddress(@"(e-mail address removed)");
MailMessage message = new MailMessage(from, to);
message.Subject = @"Using the SmtpClient class.";
message.Body = @"Using this feature, you can send an e-mail
message from an application very easily.";
SmtpClient client = new SmtpClient(@"BN002");
client.Send(message);
message.Dispose();
}
}
}



C:\Documents and Settings\Dale Hoffman\My Documents\Visual Studio
2005\Projects\
ConsoleApplication2\ConsoleApplication2\bin\Debug>consoleapplication2

Unhandled Exception: System.Net.Mail.SmtpException: Failure sending mail.
---> S
ystem.IO.IOException: Unable to read data from the transport connection:
net_io_
connectionclosed.
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer,
Int32 of
fset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader
caller, B
oolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.SmtpReplyReader.ReadLine()
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ConsoleApplication2.Program.Main(String[] args) in C:\Documents and
Settin
gs\Dale Hoffman\My Documents\Visual Studio
2005\Projects\ConsoleApplication2\Con
soleApplication2\Program.cs:line 19

C:\Documents and Settings\Dale Hoffman\My Documents\Visual Studio
2005\Projects\
ConsoleApplication2\ConsoleApplication2\bin\Debug>
 
works for me. only thing i changed was to remove all the "@" from your
strings. you dont need them in your case
 
his problem is with the config on his smtp server. probably relay or auth
settings are wrong



sloan said:
You find some permutation with smtp at my blog:
here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry



BrassicaNigra said:
I have written a very simple console application to send an email but it
always fails.

My computer (BN002) is running XP SP2 and has the default SMTP server
running in IIS. It is connected via static IP through Comcast commercail
services. I have disabled the firewall as well. I have written many
email
programs in both CDONTS and CDOSYS and have never had any problems at
all.

The code is below, followed by the error message I receive when I run it
at
the command prompt.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net.Mail;

namespace ConsoleApplication2
{
class Program
{
static void Main()
{
MailAddress from = new MailAddress(@"(e-mail address removed)");
MailAddress to = new
MailAddress(@"(e-mail address removed)");
MailMessage message = new MailMessage(from, to);
message.Subject = @"Using the SmtpClient class.";
message.Body = @"Using this feature, you can send an e-mail
message from an application very easily.";
SmtpClient client = new SmtpClient(@"BN002");
client.Send(message);
message.Dispose();
}
}
}



C:\Documents and Settings\Dale Hoffman\My Documents\Visual Studio
2005\Projects\
ConsoleApplication2\ConsoleApplication2\bin\Debug>consoleapplication2

Unhandled Exception: System.Net.Mail.SmtpException: Failure sending mail.
---> S
ystem.IO.IOException: Unable to read data from the transport connection:
net_io_
connectionclosed.
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer,
Int32 of
fset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader
caller, B
oolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader
caller)
at System.Net.Mail.SmtpReplyReader.ReadLine()
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ConsoleApplication2.Program.Main(String[] args) in C:\Documents and
Settin
gs\Dale Hoffman\My Documents\Visual Studio
2005\Projects\ConsoleApplication2\Con
soleApplication2\Program.cs:line 19

C:\Documents and Settings\Dale Hoffman\My Documents\Visual Studio
2005\Projects\
ConsoleApplication2\ConsoleApplication2\bin\Debug>
 
Thank you all for your input. It was Norton Internet Security (not sure yet
which component) that was stopping me.
 
That's what my sample code takes you thru.

None
Basic
SSL

authentications.



S Moran said:
his problem is with the config on his smtp server. probably relay or auth
settings are wrong



sloan said:
You find some permutation with smtp at my blog:
here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry



BrassicaNigra said:
I have written a very simple console application to send an email but it
always fails.

My computer (BN002) is running XP SP2 and has the default SMTP server
running in IIS. It is connected via static IP through Comcast
commercail
services. I have disabled the firewall as well. I have written many
email
programs in both CDONTS and CDOSYS and have never had any problems at
all.

The code is below, followed by the error message I receive when I run it
at
the command prompt.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net.Mail;

namespace ConsoleApplication2
{
class Program
{
static void Main()
{
MailAddress from = new
MailAddress(@"(e-mail address removed)");
MailAddress to = new
MailAddress(@"(e-mail address removed)");
MailMessage message = new MailMessage(from, to);
message.Subject = @"Using the SmtpClient class.";
message.Body = @"Using this feature, you can send an e-mail
message from an application very easily.";
SmtpClient client = new SmtpClient(@"BN002");
client.Send(message);
message.Dispose();
}
}
}



C:\Documents and Settings\Dale Hoffman\My Documents\Visual Studio
2005\Projects\
ConsoleApplication2\ConsoleApplication2\bin\Debug>consoleapplication2

Unhandled Exception: System.Net.Mail.SmtpException: Failure sending
mail.
---> S
ystem.IO.IOException: Unable to read data from the transport connection:
net_io_
connectionclosed.
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer,
Int32 of
fset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader
caller, B
oolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader
caller)
at System.Net.Mail.SmtpReplyReader.ReadLine()
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ConsoleApplication2.Program.Main(String[] args) in C:\Documents and
Settin
gs\Dale Hoffman\My Documents\Visual Studio
2005\Projects\ConsoleApplication2\Con
soleApplication2\Program.cs:line 19

C:\Documents and Settings\Dale Hoffman\My Documents\Visual Studio
2005\Projects\
ConsoleApplication2\ConsoleApplication2\bin\Debug>
 
Back
Top