public IEmail Create(Dictionary <string, string> replacements) { var siteRootContext = SitecoreContext?.GetRootItem <ISite_Root>(); var htmlEmailTemplate = HtmlEmailTemplateFactory.Create("_BaseEmail"); if (htmlEmailTemplate == null) { return(null); } var siteRoot = siteRootContext; var emailHtml = htmlEmailTemplate.Html; replacements.SetValue("#Environment#", SiteSettings.GetSetting("Env.Value", string.Empty)); replacements.SetValue("#Logo_URL#", (siteRoot?.Email_Logo != null) ? GetMediaURL(siteRoot.Email_Logo.MediaId.ToString()) : string.Empty); replacements.SetValue("#Date#", DateTime.Now.ToString("dddd, d MMMM yyyy")); replacements.SetValue("#RSS_Link_URL#", siteRoot?.RSS_Link.GetLink()); replacements.SetValue("#RssLogo#", (siteRoot?.RSS_Logo != null) ? GetMediaURL(siteRoot.RSS_Logo.MediaId.ToString()) : string.Empty); replacements.SetValue("#LinkedIn_Link_URL#", siteRoot?.LinkedIn_Link.GetLink()); replacements.SetValue("#LinkedinLogo#", (siteRoot?.Linkedin_Logo != null) ? GetMediaURL(siteRoot.Linkedin_Logo.MediaId.ToString()) : string.Empty); replacements.SetValue("#Twitter_Link_URL#", siteRoot?.Twitter_Link.GetLink()); replacements.SetValue("#TwitterLogo#", (siteRoot?.Twitter_Logo != null) ? GetMediaURL(siteRoot.Twitter_Logo.MediaId.ToString()) : string.Empty); replacements.SetValue("#Footer_Content#", GetValue(siteRoot?.Email_Footer)); emailHtml = emailHtml.ReplacePatternCaseInsensitive(replacements); var email = EmailFactory.Create(); var emailFrom = GetValue(siteRoot?.Email_From_Address); email.From = emailFrom; email.Body = emailHtml; email.IsBodyHtml = true; return(email); }