Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SMTP Send E-Mail in C#
// This will read the username, password, and mail server information from the web.config file. Very easy way to send E-Mail in .NET.
// <mailSettings>
// <smtp from="firstname lastname&lt;;">
// <network host="" port="25" userName="" password="mypassword" enableSsl="false" defaultCredentials="false" />
// </smtp>
// </mailSettings>
using System.Net.Mail;
class EMailExample
public void SendMail()
MailMessage mail = new MailMessage();
mail.To.Add(new MailAddress(""));
mail.Subject = "E-Mail Subject";
mail.Body = "This is the body of my E-Mail";
using(SmtpClient smtp = new SmtpClient())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment