Sending emails with ASP.NET

In order to send e-mails with ASP.NET, you can use the System.Net.Mail library. Here you will find examples of codes that can be used for this.

Sending text messages

If you want to send emails, formatted as plain text, through ASP.NET, you need to use the System.Net.Mail Library. Here are some simple features in the MailMessage and SMTPClient classes.

Sending HTML messages

It’s easy to send the message as HTML instead. All you have to do is put mail.IsBodyHtml to true and then use HTML in mail.Body.

Send email with authenticated user

When sending e-mail, it is recommended that you authenticate to the SMTP server to avoid the message being classified as spam. To do this, you must include the System.Net library containing the NetworkCredential class.

Send email with authenticated user + SSL

To enable SSL use the smtp.EnableSsl component that needs to be set to true.

Was this article helpful?

Related Articles