I have a program that captures customer information. It works. When I add an exception it activates the exception for all inputs including those that are valid. If I comment out the Exception it works. Here is the key portion of my code.
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
SmtpClient sc = new SmtpClient("localhost");
StringBuilder sb = new StringBuilder();
MailMessage msg = null;
sb.Append("Last Name: " + txt_Last.Text + "\n");
sb.Append("First Name: " + txt_First.Text + "\n");
sb.Append("Nick name: " + txt_Nick.Text + "\n");
sb.Append("Wife's name: " + txt_Wife.Text + "\n");
sb.Append("Email: " + txt_Email.Text + "\n");
try
{
msg = new MailMessage(txt_Email.Text,
"Web@1stSigBdeAssn.org", "Reunion Data From: " + txt_First.Text + ' ' +
txt_Last.Text,
sb.ToString());
msg.CC.Add(txt_Email.Text);
sc.Send(msg);
Response.Redirect("2012_Reunion_Registration.aspx");
}
catch(Exception ex)
{
//something bad happened
//Response.Redirect("ReunionFailure.aspx");
}
finally
{
if (msg != null)
{
msg.Dispose();
}
}
}
}
What is my problem?
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
SmtpClient sc = new SmtpClient("localhost");
StringBuilder sb = new StringBuilder();
MailMessage msg = null;
sb.Append("Last Name: " + txt_Last.Text + "\n");
sb.Append("First Name: " + txt_First.Text + "\n");
sb.Append("Nick name: " + txt_Nick.Text + "\n");
sb.Append("Wife's name: " + txt_Wife.Text + "\n");
sb.Append("Email: " + txt_Email.Text + "\n");
try
{
msg = new MailMessage(txt_Email.Text,
"Web@1stSigBdeAssn.org", "Reunion Data From: " + txt_First.Text + ' ' +
txt_Last.Text,
sb.ToString());
msg.CC.Add(txt_Email.Text);
sc.Send(msg);
Response.Redirect("2012_Reunion_Registration.aspx");
}
catch(Exception ex)
{
//something bad happened
//Response.Redirect("ReunionFailure.aspx");
}
finally
{
if (msg != null)
{
msg.Dispose();
}
}
}
}
What is my problem?