private static string SendEmail(string message, string subject, string[] mailTo) { try { var host = ConfigurationManager.AppSettings["smtp"]; var login = ConfigurationManager.AppSettings["user"]; var password = ConfigurationManager.AppSettings["password"]; var from = ConfigurationManager.AppSettings["from"]; var mailSmtp = new MailSmtp(host, login, password); mailSmtp.SendMail(from, mailTo, subject, message); return "OK"; } catch (Exception ex) { return "<span class=\"error\"><img src=\"/img/error.png\"/>" + ex.Message + "</span>"; } }
private static string SendEmail(string message, string subject, string client) { try { var host = ConfigurationManager.AppSettings["smtp"]; var login = ConfigurationManager.AppSettings["user"]; var password = ConfigurationManager.AppSettings["password"]; var from = ConfigurationManager.AppSettings["from"]; var mailSmtp = new MailSmtp(host, login, password); var mailList = new List<string>(); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["emailEmpresa1"])) mailList.Add(ConfigurationManager.AppSettings["emailEmpresa1"]); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["emailEmpresa2"])) mailList.Add(ConfigurationManager.AppSettings["emailEmpresa2"]); if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["emailEmpresa3"])) mailList.Add(ConfigurationManager.AppSettings["emailEmpresa3"]); var mailTo = mailList.ToArray(); mailSmtp.SendMail(from, mailTo, new[] { client }, subject, message); return "OK"; } catch (Exception ex) { return "<span class=\"error\"><img src=\"/img/error.png\"/>" + ex.Message + "</span>"; } }