Failure sending mail

Ranj

New Member
I'm trying to make an email page section and I found an article and one of the answer in this forum which I used in my codes below but its still saying failure sending mail which I could hardly figure out why?. I need assistance in finding a remedy why my codes below fails to send an email. Here my codes below for your reference. Please advise...Thanks.\[code\]protected void Button1_Click(object sender, EventArgs e){SmtpClient client = new SmtpClient(); client.Host = "smtp.live.com"; //Im not sure about this,I just copy it from the article client.Port = 4548; //This is my ASP.Net Development Server Port,Im not sure also if this is correct. client.Credentials = new System.Net.NetworkCredential( @"email_account", @"email_password"); //Im not sure about this code if this correct, I just copy it client.EnableSsl = true; // create message MailMessage message = new MailMessage(); message.From = new MailAddress(TextBox4.Text, "Mackmellow"); //Textbox4 is my email address message.To.Add(new MailAddress(TextBox1.Text, "Mackmellow")); // Textbox1 is the email add I want to send message.Subject = TextBox2.Text; //Textbox2 is my subject message.Body = TextBox3.Text; // Textbox3 is my message message.BodyEncoding = System.Text.Encoding.UTF8; message.IsBodyHtml = true; message.SubjectEncoding = System.Text.Encoding.UTF8; // send message try { client.Send(message); } catch (SmtpException ex) { Response.Write(ex.Message); } finally { // Clean up. message.Dispose(); }\[/code\]Can please correct my codes and tell me what I'm missing? Thanks in advance...
 
Back
Top