Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Try - Exception failure

Status
Not open for further replies.

MLNorton

Programmer
Nov 15, 2009
134
0
0
US
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?
 
Why are you adding the e-mail text body to the CC recipients? Guess that could give an overflow of some kind.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top