So using the answer found on this link:
Creating HTML from a DataTable using C#
I successfully converted by datatable to HTML and it shows as a table in my email...
I know there must be a place to put the style for adding grid lines around the cells but I for the life of me can't find the right spot. I have successfully added a border around the entire table however...
DataTable dt = new DataTable();
sdaGetValidation.Fill(dt);
StringBuilder sb = new StringBuilder();
sb.AppendLine("<html>");
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());
I am not sure if there was a way to rehash the old answer so I apologize if there is a way to do so...
Not much of an HTML guy so I feel like this should be an easy win for someone who knows it better than I.
I added 'solid line black' to this line:
sb.Append("<table border='1px' solid line black cellpadding='5' cellspacing='0' ")
But no joy....