andrewdavey / postal

Email sending for asp.net mvc using the view engine system to render emails.
http://aboutcode.net/postal
MIT License
536 stars 169 forks source link

Using FileSystemRazorViewEngine inside controller - Views data are not translated #103

Open premchandrasingh opened 9 years ago

premchandrasingh commented 9 years ago

Can't we use FileSystemRazorViewEngine from inside the controller? My requirement is to keep the mail template(Views) in a common path and use by mvc application as well as other console or windows application. In this I don't want to keep views inside the mvc app and refer by other application

[HttpPost] public ActionResult SendSimple() { var viewsPath = Server.MapPath("~/Views/Emails"); var engines = new ViewEngineCollection(); engines.Add(new FileSystemRazorViewEngine(viewsPath)); var service = new EmailService(engines);

dynamic email = new Email("Simple"); email.Date = DateTime.UtcNow.ToString(); // This does not get translated into final output service.Send(email); return RedirectToAction("Sent", "Home"); }

Same thing work from console application