Convert HTML email to a C# string
Paste the template and get output ready for C# code. The conversion runs in your browser.
The HTML is processed in your browser and not sent anywhere.
Why $@"…"?
A verbatim string ($@) keeps line breaks and backslashes as they are, and interpolation ($) lets you turn placeholders like {customer.name} into C# expressions. That is why double quotes in the HTML are doubled to "", and CSS braces inside <style> are escaped as {{ and }} so the compiler does not read them as interpolation.
Binding variables
Replace placeholders like {customer.name} in the output with variables in scope, for example {model.CustomerName}. Encode user-supplied values with WebUtility.HtmlEncode before they go into the HTML.
Frequently asked questions
Can I turn the C# output back into HTML?
Yes. The BE output panel in the editor is editable, and your edits flow back into the HTML.
Should I minify?
Not for readability; minify if you are close to Gmail's 102 KB limit.