First of all, I tried your HTML and see everything on white background, but in the Web browser. Perhaps your observations a wrong and what you see is the artifact of some defected mail viewer; I don't know what are you using to view it.
But your HTML code is bad and your table looks ugly. You are doing it wrong. Try to use better techniques:
- In your mail content, write complete HTML document, starting from the
<html><head></head><body> … </body></html>
structure. - The above item will allow you to add CSS style sheet in the
<head>
element. Do it. If you need to learn CSS, do it. - Move all your style-related formatting from table to CSS. If you need different classes for different table elements, introduce them.
- Even though your approach to composing strings using
StringBuilder
is correct, avoid doing it for such ad-hoc purposes. Instead, create some template string representing whole HTML (or say, whole HTML and, separately, a single row line) and insert actual data using string.Format
. In other words, abstract out table data from table markup. The concrete solution depends on what do you want to achieve, what is your data schema and data abstraction.
—SA