For whatever reason the web is filled with outdated examples of sending email with C#. This an example using .NET 2.0
First, be sure to import the Mail libs at the top of your class:
using System.Net.Mail;
Then in your code where the email will be sent:
MailMessage msg = new MailMessage();
msg.From = new MailAddress("from@address.com");
msg.To.Add(new MailAddress("to@address.com"));
msg.Subject = "message subject";
msg.Body = "message body";
SmtpClient smtp = new SmtpClient(”your.smtp.host”);
smtp.Send(msg);
That should do it. Feel free to post comments.
Share This