<span style=”font-weight:bold;”>Send Mail Messages Using System.Net.Mail namespace (new in .net Framework Version 2.0) which provides classes that enable you to easily create and transmit e-mail messages.</span>
Asp.net c#:
// Create a MailMessage object
MailMessage mm = new MailMessage();
// Define the sender and recipient
mm.From = new MailAddress(fromEmailAddress.Text, fromDisplayName.Text);
mm.To.Add(new MailAddress(toEmailAddress.Text, toDisplayName.Text));
// Define the subject and body
mm.Subject = subjectTextBox.Text;
mm.Body = bodyTextBox.Text;
mm.IsBodyHtml = htmlRadioButton.Checked;
// Configure the mail server
SmtpClient sc = new SmtpClient(serverTextBox.Text);
sc.EnableSsl = sslCheckBox.Checked;
if (!String.IsNullOrEmpty(usernameTextBox.Text))
sc.Credentials = new NetworkCredential(usernameTextBox.Text, passwordTextBox.Text);
// Send the message
sc.Send(mm);
//DONE
Filed under: asp.net c# | Tagged: asp.net send mail, c# send mail, mail using .net, MailMessage object, System.Net.Mail



test
hi