You have to use the System.Web.Mail namespace, which contains the MailMessage and SmtpMail classes to do the work.
MailMessage mail = new MailMessage(); mail.To = "firstname.lastname@example.org"; mail.From = "email@example.com"; mail.Subject = "Thanks for your answers!"; mail.Body = "[Flattering phrases to get faster answers next time...]"; SmtpMail.SmtpServer = "smtp.happycompany.net"; SmtpMail.Send(mail);
Dig deeper on Win Development Resources
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ...continue reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers.continue reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.