I have a script task that creates an HTML email and I can add a background image but I am having trouble getting the image to stretch to size. Everything I have read suggests using CSS but I am not very versed at HTML/CSS and even less sure of how to implement this in a script task. Here is my code:
DataTable dt = new DataTable();
sdaGetValidation.Fill(dt);
StringBuilder sb = new StringBuilder();
sb.AppendLine("<html><body {background='http://myImage.jpg'>");
sb.AppendLine("\t" + "<body>");
sb.AppendLine("\t\t" + "<table>");
sb.Append("<table border='1px' solid line black cellpadding='5' cellspacing='0' ");
sb.Append("style='border: solid 1px Silver; font-size: x-small;'>");
sb.Append("\t\t" + "<tr>");
foreach (DataColumn dc in dt.Columns)
{
sb.AppendFormat("<td>{0}</td>", dc.ColumnName);
}
sb.AppendLine("<tr>");
foreach (DataRow dr in dt.Rows)
{
sb.Append("\t\t\t" + "<tr>");
foreach (DataColumn dc in dt.Columns)
{
string cellValue = dr[dc] != null ? dr[dc].ToString() : "";
sb.AppendFormat("<td>{0}</td>", cellValue);
}
sb.AppendLine("</tr>");
}
sb.AppendLine("\t\t\t" + "</table>");
sb.AppendLine("\t" + "</body>");
sb.AppendLine("</html>");
MessageBox.Show(sb.ToString());
This line gets the image to show but it tiles:
sb.AppendLine("<html><body background='http://myImage.jpg'>");
I'm hoping this will be a quick win for someone who knows HTML better than I. Once again I keep reading that I'll need to use CSS but not even sure if that is true or how to implement CSS in this situation.