I have a C # /. NET application that currently uses StringBuilder to generate HTML email messages.
A new message format has been developed and now includes more formatting and CSS. I would like to avoid adding each line of the file using StringBuilder, so I thought it was best to include the HTML file as a resource.
However, there are about 21 variables in CSS and HTML that I need to change on the fly. My first thought was to replace them with standard String.Format placeholders ({0}, {1}, etc.), but when viewing the HTML, the checks confirm this.
I'm pretty dumb about what works best for storing a 200-line HTML file and changing parts of it before being included in an email.
Example:
In CSS, I need to change the color of some elements, for example:
#header
{
background-color: {0};
}
Inside HTML, I need to change strings and URLs, for example:
<img src="{1}" />
<span>{2}</span>
It seems that HTML as a resource in the project will be better, but trying to use String.Format with this resource, regardless of whether it will work, is a weak method due to the above validation errors.
Any suggestions?
source
share