I can't send mail

I write this code but it doesn't work. It just show "Email didn't send succesfully". I didn't know how to add UserName, Password and Port. Please help me.

private void Button1_Click(object sender, System.EventArgs e)

{

Button1.Enabled = false;

try

{

System.Web.Mail.MailMessage myMessage = new System.Web.Mail.MailMessage();

myMesage.To = txtDen.Text;

myMesage.From = txtTu.Text;

myMesage.Subject = txtCD.Text;

myMesage.Body = txtCT.Text;

myMesage.Priority = MailPriority.High;

myMesage.BodyFormat = System.Web.Mail.MailFormat.Html;

System.Web.Mail.SmtpMail SmtpMail;

SmtpMail.SmtpServer = txtSMTPServer.Text;

SmtpMail.Send(myMessage);

MessageBox.Show("Email sent successfully", "Alert", MessageBoxButtons.OK);

}

catch

{

MessageBox.Show("Email disn't sent successfully", "Alert", MessageBoxButtons.OK);

}

Button1.Enabled = true;

}



Answer this question

I can't send mail