public override void InitializeFromXml(XElement e) { if (null != e) { e = e.Element("messaging"); } if (null != e) { foreach (var element in e.Elements("smtp")) { var conf = new SmtpConfig { Code = element.Attr("code"), From = element.Attr("name"), Host = element.Attr("host"), Port = element.Attr("port").ToInt(), SslRequired = element.Attr("ssl").ToBool(), User = element.Attr("user"), Name = element.Attr("title") }; var _password = element.Attr("pass"); var p = new SecureString(); foreach (var c in _password) { p.AppendChar(c); } conf.Password = p; Registry[conf.Code] = conf; Registry[conf.From] = conf; if (e.Attr("default").ToBool()) { Registry["default"] = conf; } } } }
private static MailMessage BuildMessage(PostMessage message, SmtpConfig conf) { var m = new MailMessage { From = new MailAddress(conf.From, conf.Name), BodyEncoding = Encoding.UTF8, IsBodyHtml = true, Body = message.Body, SubjectEncoding = Encoding.UTF8, Subject = message.Subject }; m.Body += "<div style='color:gray;font-size:8pt'>messageid:" + message.Id + "</div>"; if (message.Type != "subscribe") { m.Subject += "; messageid:" + message.Id; } foreach (var address in message.Addresses) { m.Bcc.Add(new MailAddress(address)); } m.Bcc.Add(conf.From); return m; }