Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi guys,
I've set up a document type and an Umbraco template for use for email templates on my site. Now I basically have a page which html I need to read and use in emails.
I found a helper which presumably does half of the work (couldn't test it yet though) here: http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/render-razor-scripts-for-emails-and-more/create-string-of-partial-view-for-emailing
public static string RenderPartialViewToString(Controller controller, string viewName, object model) { controller.ViewData.Model = model; try { using (StringWriter sw = new StringWriter()) { ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName); ViewContext viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw); viewResult.View.Render(viewContext, sw); return sw.GetStringBuilder().ToString(); } } catch (Exception ex) { return ex.ToString(); } }
This method accepts a controller as a parameter, but I can't figure out how to create the controller I need.
I guess it's not the only way to do it, can anyone advice on it? Any help will be greatly appreciated.
Thank you.
P.S. I use Umbraco 6.1.6
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Render view result as a string for emailing
Hi guys,
I've set up a document type and an Umbraco template for use for email templates on my site. Now I basically have a page which html I need to read and use in emails.
I found a helper which presumably does half of the work (couldn't test it yet though) here: http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/render-razor-scripts-for-emails-and-more/create-string-of-partial-view-for-emailing
This method accepts a controller as a parameter, but I can't figure out how to create the controller I need.
I guess it's not the only way to do it, can anyone advice on it? Any help will be greatly appreciated.
Thank you.
P.S. I use Umbraco 6.1.6
is working on a reply...