using System; using System.Net; using System.Net.Mail; namespace TestClient { class Program { public static void Main (string[] args) { MailAddress to = new MailAddress("ToAddress"); MailAddress from = new MailAddress("FromAddress"); MailMessage email = new MailMessage(from, to); email.Subject = "Testing out email sending"; email.Body = "Hello all the way from the land of C#"; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.server.address"; smtp.Port = 25; smtp.Credentials = new NetworkCredential("smtp_username", "smtp_password"); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.EnableSsl = true; try { /* Send method called below is what will send off our email * unless an exception is thrown. */ smtp.Send(email); } catch (SmtpException ex) { Console.WriteLine(ex.ToString()); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)