Email Code OK in debug mode...error when runs outside vwd

S

.spider

Hi,
I have a code here (taken from http://www.dotnetwatch.com/page294.aspx).
Now i didn't think there was anything wrong with this code(no
compilation errors..nothing)..and infact when i ran this code in
visual web developer in the debug mode, the code DID mail to the
recipient email id. However, after uploading the codes to my hosting
account, upon submiting the form(which sends contents of 'TextBox1'
and 'TextBox3' to (e-mail address removed)), a browser message popped up reading
this : 'sys.webform.pagerequestmanagerservererrorException : an
unknow.error occurred while processing the request on the server the
status code teturned from sever is 500
'
CODE:
_____________
protected void ImageButton1_Click(object sender, ImageClickEventArgs
e)
{
if (Process(TextBox1.Text) == true)
{
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("(e-mail address removed)", "(e-mail address removed)",
"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("(e-mail address removed)", "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;
}
}
_____________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top