I have a form that a user can enter their email address and click the submit button. Then the user will get an email with their password in it. When I test the form and enter in an email address and click submit the form takes a while to go through and then it times out. The error is:
The operation has timed out. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Mail.SmtpException: The operation has timed out.
The Trace is:
Stack Trace:
[SmtpException: The operation has timed out.]
System.Net.Mail.SmtpClient.Send(MailMessage message) +1798
ForgotPassword.btnPass_Click(Object sender, EventArgs e) in C:\Users\khopkins\Documents\Visual Studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\ForgotPassword.aspx.cs:67
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9552874
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
The Code is:
protected void btnPass_Click(object sender, EventArgs e)
{
string strConnection = ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString;
string strSelect = "select INST_ID, EmailAddress, Password from Tablepass where EmailAddress ='" + TextBoxEA.Text.Trim() + "'";
SqlConnection connection = new SqlConnection(strConnection);
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = strSelect;
SqlParameter email = new SqlParameter("@EmailAddress", TextBoxEA.Text.Trim());
email.Value = TextBoxEA.Text.Trim().ToString();
command.Parameters.Add(email);
DataSet dsPwd = new DataSet();
connection.Open();
SqlDataAdapter dAdapter = new SqlDataAdapter(command);
dAdapter.Fill(dsPwd);
connection.Close();
if (dsPwd.Tables[0].Rows.Count > 0)
{
MailMessage loginInfo = new MailMessage();
loginInfo.To.Add(TextBoxEA.Text.ToString());
loginInfo.From = new MailAddress("Admin@fastfix.com", "Southern Association of Colleges and Schools Commission on Colleges");
loginInfo.Subject = "Forgot Password Information";
loginInfo.Body = "EmailAddress: " + dsPwd.Tables[0].Rows[0]["EmailAddress"] + "<br /><br />Password: " + dsPwd.Tables[0].Rows[0]["Password"] + "<br /><br />";
loginInfo.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("mail.fastfix.com");
smtp.Host = "mail.sacscoc.org";
smtp.Port = 80;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("@EamilAddress", "YourEmailPassword");
smtp.Send(loginInfo);
lblMessage.Text = "Password is sent to your email<a href='Login.aspx'>Login</a>";
try
{
smtp.Send(loginInfo);
}
catch (Exception ex)
{
lblMessage.Text = "Oops, Something Went Wrong When We Tried to Send The Email";
return;
}
}
else
{
lblMessage.Text = "Email Address Not Registered";
}
}
}
What did I do wrong to get this error? Is there a way to fix it?