public static OutMailInformation GetMailInformation(string templatePath) { OutMailInformation mailInformation = new OutMailInformation(); try { XmlDocument doc = new XmlDocument(); string xmlTemplatePath = HttpContext.Current.Server.MapPath(templatePath); doc.Load(xmlTemplatePath); if (doc.GetElementsByTagName("to").Item(0) != null) { mailInformation.to = doc.GetElementsByTagName("to").Item(0).InnerText; } if (doc.GetElementsByTagName("subject").Item(0) != null) { mailInformation.subject = doc.GetElementsByTagName("subject").Item(0).InnerText; } if (doc.GetElementsByTagName("message").Item(0) != null) { mailInformation.message = doc.GetElementsByTagName("message").Item(0).InnerText; } } catch (Exception ex) { LogHelper.WriteLog("Helper", "Utilities", "GetMailRecipient", ex, ""); } return(mailInformation); }
public ActionResult MailPwd() { var msg = ""; if (TempData["user"] != null) { var usr = (OutValidateUser)TempData["user"]; int contador = 0; Mail send = new Mail(); OutMailInformation info = Utilities.GetMailInformation("~/Templates/TemplateChangePasswordMail.xml"); info.message = info.message.Replace(":nombreAgente", usr.userName).Replace(":documentoAgente", usr.userID); send.EnviarCorreo(info.to, "", "", info.subject, info.message, ref contador); msg = "Se ha enviado un correo con su solicitud de Cambio de Clave."; } TempData["msgCambio"] = msg; return(RedirectToAction("Index")); }