.NET convert external CSS to inline CSS

I'm looking for a tool that converts external CSS to inline CSS. The resulting HTML is used in e-mail and for PDF creation.


Premailer.Net should do the trick it's written in C#

C# .Net library, that moves your stylesheets to inline style attributes, for maximum compatibility with E-mail clients.

Here is the Git repo: https://github.com/milkshakesoftware/PreMailer.Net:


Using .NET Core, I solved this problem by defining a function as follows

public static string InlineFile(string path)
{
    return System.IO.File.ReadAllText("wwwroot/" + path);
}

and then calling it in a view as

<style>
    @Html.Raw(Utilities.InlineFile("account/css/style.css"));
</style>

The reason behind separately defining the function is to avoid changing all paths in case the hosting environment changes. Beware that you cannot inline media rules.


http://beaker.mailchimp.com/inline-css

链接地址: http://www.djcxy.com/p/4976.html

上一篇: 如何在Java中实现OAuth提供程序?

下一篇: .NET将外部CSS转换为内联CSS