Sending a basic email message in a C# application is quite easy thanks to a class called SmptClient. We simply need an address to send to, an address to send from, the message we want to send and the address of an SMTP server, hand it all to the SMTP client, and you’re done:
var to = new MailAddress("firstname.lastname@example.org", "You");
var message = new MailMessage(from, to)
Subject = "Greetings!",
Body = "How are you doing today?",
var client = new SmtpClient("smtp.example.com");
catch (SmtpException e)
That was pretty simple, wasn’t it? But what if we need to authenticate with our server? And what if we want to send our message in a more secure manner?