Start a conversation

ASP.NET sample send mail code

Using System.Net.Mail;

=====================



MailMessage mailMessage = new MailMessage();

mailMessage.From = new MailAddress("noreply@yourdomain.com");

mailMessage.To.Add(new MailAddress(txtEmail.Text));


string emailBody = "Test Asp.net Send Mail";

mailMessage.IsBodyHtml = true;

mailMessage.Subject = "Asp.Net Send mail";

mailMessage.Body = emailBody;


SmtpClient smtpClient = new SmtpClient();

smtpClient.Send(mailMessage);

lblInfo.Text = "Email has been sent";

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Romana Akther

  2. Posted
  3. Updated

Comments

  1. Kazi Mehedi Hasan

    That is great
  2. Md. Rifat

    Thanks, u.