public override string Merge(Parameters p) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(base.Merge(p)); XmlNode root = xmlDoc.DocumentElement; mailMessage.Subject = root.SelectSingleNode("subject").InnerText.Replace("\r\n", string.Empty); mailMessage.From = new MailAddress(root.SelectSingleNode("addresses/entry[@name=\"From\"]/@value").InnerText.Replace("\r\n", string.Empty)); XmlNodeList recipients = root.SelectNodes("addresses/entry[@name=\"To\"]/@value"); StringBuilder sb = new StringBuilder(); foreach (XmlNode node in recipients) { mailMessage.To.Add(new MailAddress(node.InnerText.Replace("\r\n", string.Empty))); } XmlNodeList repliers = root.SelectNodes("addresses/entry[@name=\"ReplyTo\"]/@value"); foreach (XmlNode node in repliers) { mailMessage.ReplyTo =new MailAddress(node.InnerText.Replace("\r\n", string.Empty)); } XmlNodeList attachments = root.SelectNodes("attachments/file/@path"); foreach (XmlNode node in attachments) { mailMessage.Attachments.Add(new Attachment(node.InnerText.Replace("\r\n", string.Empty))); } XmlNode bodyNode = root.SelectSingleNode("body"); mailMessage.Body = bodyNode.FirstChild.InnerText.Replace("\r\n", string.Empty); mailMessage.IsBodyHtml = true; return xmlDoc.InnerXml; }
public void Send(Parameters para, EmailTemplate template) { try { template.Merge(para); smtpClient.Send(template.MailMessage); } catch (Exception ex) { throw ex; } }
public ContactUsEmail(string name, string email, string phone, string address, string company, string subject, string message) { parameters = new Parameters(); parameters.AddParameter("From", email); parameters.AddParameter("Name", name); parameters.AddParameter("Phone", phone); parameters.AddParameter("To", DBNLConfigurationManager.Emails.ContactFormEmailAddress); parameters.AddParameter("Body", message); parameters.AddParameter("Subject", subject); parameters.AddParameter("Company", company); parameters.AddParameter("Address", address); template = new EmailTemplate(HttpContext.Current.Server.MapPath("~/App_Data/EmailTemplates/ContactUsTemplate.xml")); }
public virtual void PrepareParameter() { try { if (parameters == null) parameters = new Parameters(); parameters.AddParameter("RootUrl", WebUtility.RootUrl); } catch (Exception ex) { } }
public virtual string Merge(Parameters p) { TemplateParser parser = new TemplateParser(p); parser.SetTemplate(this.src); return parser.Parse(); }