public DTOMessage GetMessage(string messageName) { DTOMessage message = null; // Compile a standard XPath expression if (doc == null || nsmgr == null) { return(null); } XmlNode msgNode; msgNode = doc.DocumentElement.SelectSingleNode("/email-list/email[@name='" + messageName + "']"); if (msgNode != null && msgNode.ChildNodes.Count == 2) { message = new DTOMessage(msgNode.ChildNodes[0].InnerText, msgNode.ChildNodes[1].InnerText); if (msgNode.Attributes["cc"] != null) { string ccList = msgNode.Attributes["cc"].InnerText; message.CcList = ccList.Split(new char[] { ',', ';' }); } } return(message); }
private void SendEmail(UserStoryAttachment diagramObject, string userId, string template) { MailService mailService = MailService.Instance; string _mailConfigFilePath = AppDomain.CurrentDomain.GetData("DataDirectory") + "\\Mail.xml"; mailService.LoadFile(_mailConfigFilePath); DTOMessage message = mailService.GetMessage(template); string sendFrom = (ConfigurationSettings.AppSettings["MailFromAddress"] != null) ? ConfigurationSettings.AppSettings["MailFromAddress"].ToString() : ""; UserRepository uRepositorty = new UserRepository(); var actionUser = uRepositorty.FindById(userId); diagramObject.UserStory.AspNetUsers.ToList().ForEach(f => { string messageSubject = MailService.formatMsg(message.Subject, new string[] { diagramObject.Attachment.name.ToString() }); string bodyStr = MailService.formatMsg(message.Body, new string[] { diagramObject.Attachment.name.ToString(), f.UserName, actionUser.UserName, diagramObject.UserStory.name }); MailService.SendMessageWithAttachment(sendFrom, f.Email, null, messageSubject, bodyStr, null); }); }