4
Answers

How to Send Email In Asp.net 2.0

Dipali Patil

Dipali Patil

12y
8.5k
1

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)