Emailing Code works fine in debug mode, BUT NOT when uploaded

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,
This code emails the contents of 'TextBox1' and 'TextBox3' to
rcv@xxxxxxxxxxxx this code seemed to be working fine in debug mode and
DID mail rcv@xxxxxxxxxx However when i uploaded the website to my
hosting account, my browser popped up and alertbox saying:
"Sys.WebForms.PageRequestServerManagerErrorException An unknown error
occured while processing the request on the server. The status code
returned from the server was : 500"

CODE
----------------------------
protected void ImageButton1_Click(object sender, ImageClickEventArgs
e)
{
if (Process(TextBox1.Text) == true) //Checks if supplies
string is a valid email type or not
{ //
There was a good reason to do it server side as it was locking up
//
other controls
Label1.Text = null;
//Create Mail Message Object with content that you want to
send with mail.
System.Net.Mail.MailMessage MyMailMessage = new
System.Net.Mail.MailMessage("snd@xxxxxxxxx", "rcv@xxxxxxxxxx",
"WebVisitor:" + DateTime.Now.ToString("MMMM dd yyyy"),
"email: " + TextBox1.Text + "\nquery: " + TextBox3.Text);

MyMailMessage.IsBodyHtml = false;

//Proper Authentication Details need to be passed when
sending email from gmail
System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential("send@xxxxxxxxx", "password");

//Smtp Mail server of Gmail is "smpt.gmail.com" and it
uses port no. 587
System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

//Enable SSL
mailClient.EnableSsl = true;

mailClient.UseDefaultCredentials = false;

mailClient.Credentials = mailAuthentication;

mailClient.Send(MyMailMessage);

TextBox1.Text = null;
TextBox3.Text = null;
}
else
{
Label1.Text = "is INVALID";
TextBox1.Text = null;
}
}
----------------------------

.


Quantcast