using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Mail; using System.Net; namespace sharpknife.Commands { public class SendMailCommand : Command { private static string SMTP_HOST = "mail.eugeniofavalli.eu"; private static int SMTP_PORT = 25; private static string USERNAME = "eugeniofavalli.eu76409"; private static string PASSWORD = "zyIO1920!"; private static string FROM = "ptc@eugeniofavalli.eu"; private static string TO = "eugeniofavalli@gmail.com"; public string Subject { get; set; } public string Body { get; set; } public SendMailCommand(string subject, string body) { this.Group = "Mail"; this.Subject = subject; this.Body = body; } public override void Execute() { base.Execute(); SmtpClient client = new SmtpClient(SMTP_HOST, SMTP_PORT) { Credentials = new NetworkCredential(USERNAME, PASSWORD), EnableSsl = true }; client.Send(FROM, TO, Subject, Body); Debug = "Sent"; Status = StatusCode.Completed; } } }