Hi,
This code emails the contents of 'TextBox1' and 'TextBox3' to
rcv@domain.com.. this code seemed to be working fine in debug mode and
DID mail rcv@domain.com 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@gmail.com", "rcv@domain.com",
"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@gmail.com", "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;
}
}
----------------------------
bruce barker - 17 Jul 2007 15:59 GMT
check that port 587 is open from your hosting server.
-- bruce (sqlwork.com)
> Hi,
> This code emails the contents of 'TextBox1' and 'TextBox3' to
[quoted text clipped - 55 lines]
> }
> ----------------------------
Juan T. Llibre - 17 Jul 2007 16:46 GMT
Try:
!> System.Net.Mail.MailMessage("snd", "rcv@domain.com",
instead of
!> System.Net.Mail.MailMessage("snd@gmail.com", "rcv@domain.com",
Also, you have to setup your Gmail account for POP3 access.
There's instructions for doing that at the Gmail site.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
> Hi,
> This code emails the contents of 'TextBox1' and 'TextBox3' to
[quoted text clipped - 55 lines]
> }
> ----------------------------