I need to provide a variable bit of data (the "body" of an email) to a (string) member of a list of string, and am trying to build it using string.format, but I get, ") expected" on the "http" part here:
string htmlBodyAmalgamation = string.Format(@"<html><body><img src=\"http://www.platypus.com/wp-
content/themes/platypus/images/pa_logo_notag.png\" alt=\"Platypus logo\" width=\"199\" height=\"130\" ><p>{0}</p>", body);
I get that err msg whether I have 0, 1, 2, or 3 backwhacks ("\") prepended to the "http".
If there is no variable portion (if the body is static/known in advance) I can do this:
List<String> htmlBody = new List<string>
{
"<html><body><img src=\"http://www.platypus.com/wp-content/themes/platypus/images/pa_logo_notag.png\" alt=\"Platypus logo\" width=\"199\" height=\"130\" ><p>Your Platypus Price Push report is attached.</p>",
"</body></html>"
};
mailItem.HTMLBody = string.Join(Environment.NewLine, htmlBody.ToArray());
...and it works fine.
So it's trying to embed the variable "body" value via string.format as follows that is proving problematic:
string htmlBodyAmalgamation = string.Format(@"<html><body><img src=\"http://www.platypus.com/wp-content/themes/platypus/images/pa_logo_notag.png\" alt=\"Platypus logo\" width=\"199\" height=\"130\" ><p>Your Platypus Price Push report is attached.</p>", body);
List<String> htmlBody = new List<string>
{
htmlBodyAmalgamation,
"</body></html>"
};
What's the trick to get the html and string.format to work together?