How to include CSS styles inline in Razor view?

asp.net-mvc, asp.net-mvc-4, postal, razor

Solution

I guess you will need to have a custom helper for that. On top of my head, there is no such a method to render the css path including the absolute path of the website.

e.g. http:www.example.com/css/EmailStyles.css

Problem

I am using Postal to render MVC Razor views and send them via email. I have a custom CSS that I have defined specifically for the email views. Currently I am including them as follows: ``` @Styles.Render("~/Content/EmailStyles.css") ``` However, this only includes the relative link to the stylesheet, which will not work in an email: ``` <link href="/Content/EmailStyles.css" rel="stylesheet"/> ``` I want to include the stylesheet inline so that it functions properly in the email. What is the best way to render the contents of a file-based resource within an MVC view?

Original source