Dipali Patil

Dipali Patil

  • NA
  • 72
  • 79.2k

How to Send Email In Asp.net 2.0

Oct 25 2010 5:10 AM

How to Send Email In Asp.net 2.0 ?
 
I use following code but it is not work ......
string UserFNameCase = txtname.Text;
string dsCenter = ddlDistribution.SelectedItem.Text;
string MailSub = "Registration Information.";
string EventDescription = "<html><body> Dear " + UserFNameCase + ", <br /> Your Serial No is <b>" + SerialNo + "</b> . Please collect your Id card From <b>" + dsCenter + " </b> after 2 bussiness days .</body></html>";
MailMessage mail = new MailMessage();
mail.IsBodyHtml = true;
mail.Subject = "Registration Information.";
mail.Body = EventDescription;
mail.From = new MailAddress("[email protected]");
mail.To.Add(txtEmail.Text);
SmtpClient smtp = new SmtpClient("localhost");
//smtp.Host = "127.0.0.1";
smtp.Host = "LocalHost";
smtp.Credentials = new NetworkCredential("username", "secret");
////smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.Send(mail);
 

Answers (4)