Mega Code Archive

 
Categories / C# Book / 08 Net
 

0604 Sending Mail with SmtpClient

The SmtpClient class in the System.Net.Mail namespace allows you to send mail messages through the Simple Mail Transfer Protocol. To send a simple text message, instantiate SmtpClient, set its Host property to your SMTP server address, and then call Send: using System; using System.Net; using System.Net.Mail; using System.Threading; using System.IO; using System.Text; class ThreadTest { static void Main() { SmtpClient client = new SmtpClient(); client.Host = "mail.myisp.net"; client.Send("from@adomain.com", "to@adomain.com", "subject", "body"); } }