SMTP failure

C

Chubbly Geezer

Hi
I am using the following code to send an email from within my program:-

MailMessage theMailMessage = new MailMessage("(e-mail address removed)", "(e-mail address removed)");
theMailMessage.Body = "body email message here";
theMailMessage.Attachments.Add(new Attachment("pathToEmailAttachment"));
theMailMessage.Subject = "Subject here";

SmtpClient theClient = new SmtpClient("IP.Address.Of.Smtp");
theClient.UseDefaultCredentials = false;
System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential("(e-mail address removed)", "password");
theClient.Credentials = theCredential;
theClient.Send(theMailMessage);

however I keep getting the following error:-

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
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 SubsUtilGeneric.SubsUtilities.AdminEmail(String PubCode, String eSubject, String eBody) in C:\WARC\VB.Net\SubsUtilGeneric\SubsUtilities.vb:line 1799

Any ideas please.?

Chubbly
 
S

sloan

2/8/2006
Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)

http://sholliday.spaces.live.com/blog/

If you go there, you can download the code, and experiment with the different authentication modes.


...........



Hi
I am using the following code to send an email from within my program:-

MailMessage theMailMessage = new MailMessage("(e-mail address removed)", "(e-mail address removed)");
theMailMessage.Body = "body email message here";
theMailMessage.Attachments.Add(new Attachment("pathToEmailAttachment"));
theMailMessage.Subject = "Subject here";

SmtpClient theClient = new SmtpClient("IP.Address.Of.Smtp");
theClient.UseDefaultCredentials = false;
System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential("(e-mail address removed)", "password");
theClient.Credentials = theCredential;
theClient.Send(theMailMessage);

however I keep getting the following error:-

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
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 SubsUtilGeneric.SubsUtilities.AdminEmail(String PubCode, String eSubject, String eBody) in C:\WARC\VB.Net\SubsUtilGeneric\SubsUtilities.vb:line 1799

Any ideas please.?

Chubbly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top