By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,132 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,132 IT Pros & Developers. It's quick & easy.

Some get error failure sending mail ( System.Net.Mail)

P: n/a
Using System.Net.Mail: Sometimes I get error 'failure sending mail.
Unable to write data to the transport connection: An existing
connection was forcibly closed by the remote host.' Not sure how to
fix this error.

I am able to send messages sometimes both other times randomly
following error appear
EXCEPTION:
Exception of type 'System.Web.HttpUnhandledException' was thrown.
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context
context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.coursecert_presenter_main_aspx.ProcessRequest( HttpContext
context)
at
System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApplication.IExecutionStep.Execut e()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)
INNER EXCEPTION:
Failure sending mail.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at coursecert.utility.SendEmail(Object from_email, Object
from_name, Object to_email, Object email_subject, Object
email_message)
at coursecert.utility.SendAMail(String email_subject, String
email_message, Int32 cert_tracking_id, String email_to)
at ASP.coursecert_presenter_main_aspx.SendMail(Int32 message_ind)
at
ASP.coursecert_presenter_main_aspx.btnSendtoPRODUC TION_click(Object
sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEven t(String
eventArgument)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection
postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint)
INNER EXCEPTION:
Unable to write data to the transport connection: An existing
connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32
size)
at System.Net.Mail.SmtpConnection.Flush()
at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String&
response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[]
command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
INNER EXCEPTION:
An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset,
Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
offset, Int32 size)

Sep 21 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
>An existing connection was forcibly closed by the remote host

Without seeing any code, the first thing that comes to mind (and has caught
me on a few projects) has been various anti-virus softwares blocking port
25 or the SMTP server you're using hasn't been provided with the correct
authentication information.

If you can, post up your code.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com
Using System.Net.Mail: Sometimes I get error 'failure sending mail.
Unable to write data to the transport connection: An existing
connection was forcibly closed by the remote host.' Not sure how to
fix this error.

I am able to send messages sometimes both other times randomly
following error appear

EXCEPTION:
Exception of type 'System.Web.HttpUnhandledException' was thrown.
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context
context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.coursecert_presenter_main_aspx.ProcessRequest( HttpContext
context)
at
System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApp
lication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)
INNER EXCEPTION:
Failure sending mail.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at coursecert.utility.SendEmail(Object from_email, Object
from_name, Object to_email, Object email_subject, Object
email_message)
at coursecert.utility.SendAMail(String email_subject, String
email_message, Int32 cert_tracking_id, String email_to)
at ASP.coursecert_presenter_main_aspx.SendMail(Int32 message_ind)
at
ASP.coursecert_presenter_main_aspx.btnSendtoPRODUC TION_click(Object
sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEven t(String
eventArgument)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.R
aisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection
postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint)
INNER EXCEPTION:
Unable to write data to the transport connection: An existing
connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32
size)
at System.Net.Mail.SmtpConnection.Flush()
at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String&
response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[]
command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
INNER EXCEPTION:
An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset,
Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
offset, Int32 size)

Sep 21 '07 #2

P: n/a
On Sep 21, 11:24 am, David R. Longnecker
<dlongnec...@community.nospamwrote:
An existing connection was forcibly closed by the remote host

Without seeing any code, the first thing that comes to mind (and has caught
me on a few projects) has been various anti-virus softwares blocking port
25 or the SMTP server you're using hasn't been provided with the correct
authentication information.

If you can, post up your code.

-dl

--
David R. Longneckerhttp://blog.tiredstudent.com
Using System.Net.Mail: Sometimes I get error 'failure sending mail.
Unable to write data to the transport connection: An existing
connection was forcibly closed by the remote host.' Not sure how to
fix this error.
I am able to send messages sometimes both other times randomly
following error appear
EXCEPTION:
Exception of type 'System.Web.HttpUnhandledException' was thrown.
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context
context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.coursecert_presenter_main_aspx.ProcessRequest( HttpContext
context)
at
System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApp
lication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step,
Boolean& completedSynchronously)
INNER EXCEPTION:
Failure sending mail.
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at coursecert.utility.SendEmail(Object from_email, Object
from_name, Object to_email, Object email_subject, Object
email_message)
at coursecert.utility.SendAMail(String email_subject, String
email_message, Int32 cert_tracking_id, String email_to)
at ASP.coursecert_presenter_main_aspx.SendMail(Int32 message_ind)
at
ASP.coursecert_presenter_main_aspx.btnSendtoPRODUC TION_click(Object
sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEven t(String
eventArgument)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.R
aisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection
postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint)
INNER EXCEPTION:
Unable to write data to the transport connection: An existing
connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32
size)
at System.Net.Mail.SmtpConnection.Flush()
at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String&
response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[]
command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
INNER EXCEPTION:
An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset,
Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32
offset, Int32 size)- Hide quoted text -

- Show quoted text -

Here is the code.. It work fine sometimes, but when this function is
called repealy, then it break down!..
Sub sendAmail()
Dim send_mail_ip As String =
System.Configuration.ConfigurationManager.AppSetti ngs("send_mail_ip")
Dim mail As New MailMessage()

If Trim(txtToEmail.Text) <String.Empty And
Trim(send_mail_ip) <String.Empty Then
Dim smtp As New SmtpClient(Trim(send_mail_ip))
mail.From = New MailAddress(Trim(txtFromEmail.Text),
Trim(txtFromEmail.Text))
mail.To.Add(Trim(txtToEmail.Text))
mail.Subject = txtSubject.Text
mail.Body = txtMessage.Text

smtp.Send(mail)

lblAlert.Text = "<font color =""green"">Email Send</font>"
End If

End Sub

Sep 21 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.