public ActionResult _PreviewNewsMail(string Title, string Description) { PreviewNewsMailViewModel model = new PreviewNewsMailViewModel(); try { model = _newsService.GetPreviewNewsMailViewModel(Title, Description, UserSession); } catch (Exception e) { Commons.Logger.GenerateError(e, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); return(null); } return(PartialView(model)); }
public PreviewNewsMailViewModel GetPreviewNewsMailViewModel(string Title, string Description, UserSession user) { PreviewNewsMailViewModel model = new PreviewNewsMailViewModel(); try { if (Title == null) { Title = ""; } if (Description == null) { Description = ""; } List <Tuple <string, string> > GenericEmailContent = EMailHelper.GetGenericEmailContent(); GenericEmailContent.Add(new Tuple <string, string>("#UserFirstName#", user.FirstName)); GenericEmailContent.Add(new Tuple <string, string>("#UserFullName#", user.UserFullName)); GenericEmailContent.Add(new Tuple <string, string>("#RealUserEMail#", "")); GenericEmailContent.Add(new Tuple <string, string>("#WebSiteURL#", Utils.Website)); GenericEmailContent.Add(new Tuple <string, string>("#WatcherUrl#", FileHelper.GetStorageRoot(DefaultImage.Empty))); string BasePathFile = FileHelper.GetRootPathDefault() + @"\" + Const.BasePathTemplateEMails.Replace("~/", "\\"); string PathHeaderOnServer = BasePathFile + "\\_HeaderMail.html"; string PathFooterOnServer = BasePathFile + "\\_FooterMail.html"; string PathEndMailOnServer = BasePathFile + "\\_EndMail_en.html"; string PathTemplateOnServer = BasePathFile + "\\news_en.html"; string headerTemplate = System.IO.File.ReadAllText(PathHeaderOnServer); string bodyTemplate = System.IO.File.ReadAllText(PathTemplateOnServer); string footerTemplate = System.IO.File.ReadAllText(PathFooterOnServer); string endMailTemplate = System.IO.File.ReadAllText(PathEndMailOnServer); model.Body = headerTemplate + bodyTemplate + endMailTemplate + footerTemplate; foreach (var content in GenericEmailContent) { model.Body = model.Body.Replace(content.Item1, content.Item2); } model.Body = model.Body.Replace("#Title#", Title).Replace("#Description#", Description); } catch (Exception e) { Commons.Logger.GenerateError(e, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Title = " + Title); } return(model); }