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

S

.spider

Hi,
This code emails the contents of 'TextBox1' and 'TextBox3' to
(e-mail address removed).. this code seemed to be working fine in debug mode and
DID mail (e-mail address removed) 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("(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;
}
}
----------------------------
 
J

Juan T. Llibre

Try:

!> System.Net.Mail.MailMessage("snd", "(e-mail address removed)",

instead of
!> System.Net.Mail.MailMessage("(e-mail address removed)", "(e-mail address removed)",

Also, you have to setup your Gmail account for POP3 access.
There's instructions for doing that at the Gmail site.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top