andrewdavey / postal

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

Html Helpers in non asp.net project #96

Closed fsepoy closed 9 years ago

fsepoy commented 9 years ago

Hi, I'm trying to use postal in a non mvc app but I cannot use the @Html.EmbedImage to embed an image into an email. I have seen suggestions on using a custom base template for RazorEngine //http://stackoverflow.com/a/19434112 but how could I implement that with the FileSystemRazorViewEngine.

Any help would be appreciated. I'd hate to have to abandon this project.

Thanks.

andrewdavey commented 9 years ago

Have you tried calling: Razor.SetTemplateBase(typeof(MyCustomTemplateBase<>)); in Application_Start?

fsepoy commented 9 years ago

Razor only has a SetTemplateService() method. I tried the below code but the missing image imbedder throws an error. I have had to abandon trying to get this to work in console apps. Sadly I got to go back to the old fashion way of doing things.

        TemplateServiceConfiguration templateConfig = new TemplateServiceConfiguration
        {
            BaseTemplateType = typeof(RazorEngineBaseTemplate<>)
        };
        Razor.SetTemplateService(new TemplateService(templateConfig));

Thanks for the help though and kudos for a great tool that works brilliantly in MVC.