0
votes

I'd like to compile css and replace the resulting styles for each tag as an inline style for the corresponding tags in html. Is there a simple way to do this in c#?

This is similar to "Compile" CSS into HTML as inline styles - but I want to do it in c#

1

1 Answers

4
votes

You can use https://github.com/milkshakesoftware/PreMailer.Net

 string htmlSource = File.ReadAllText(@"C:\Workspace\testmail.html");

 var result = PreMailer.MoveCssInline(htmlSource);

 result.Html         // Resultant HTML, with CSS in-lined.
 result.Warnings     // string[] of any warnings that occurred during processing.