Handling email in C #
5 answers
You need the System.Net.Mail namespace.
Here's an example from the ScottGu blog.
MailMessage message = new MailMessage();
message.From = new MailAddress("sender@foo.bar.com");
message.To.Add(new MailAddress("recipient1@foo.bar.com"));
message.To.Add(new MailAddress("recipient2@foo.bar.com"));
message.To.Add(new MailAddress("recipient3@foo.bar.com"));
message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
+6
a source to share
In addition to Ekeko's answer, if you want to use an external mail server, you must specify the host in the SmtpClient constructor.
SmtpClient client = new SmtpClient("mail.yourmailserver.com");
And you might also need authentication if your server requires it.
client.Credentials = new NetworkCredential("username", "password");
+2
a source to share