Here is a basic version to create a message. You can adapt to your code and add formatting.
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace SampleNamespace.Classes
{
public class DataOperations
{
private static readonly string ConnectionString =
"Data Source=.\\sqlexpress;Initial Catalog=DataGridViewCodeSample;Integrated Security=True";
public static string CreateMessage()
{
StringBuilder builder = new StringBuilder();
var dtColor = new DataTable();
using (var cn = new SqlConnection { ConnectionString = ConnectionString })
{
using (var cmd = new SqlCommand { Connection = cn })
{
cn.Open();
cmd.CommandText = "SELECT ColorId,ColorText FROM Colors ORDER BY ColorText";
dtColor.Load(cmd.ExecuteReader());
builder.AppendLine("<P>");
builder.AppendLine(" <table>");
foreach (DataRow row in dtColor.Rows)
{
builder.AppendLine(" <tr>");
builder.AppendLine($" <td>{row.Field<int>("ColorId")}</td><td>{row.Field<string>("ColorText")}</td>");
builder.AppendLine(" </tr>");
}
builder.AppendLine(" </table>");
builder.AppendLine("<P>");
}
}
return builder.ToString();
}
}
}
Output
<P>
<table>
<tr bgcolor='#4da6ff'>
<td>7</td><td>Black</td>
</tr>
<tr bgcolor='#4da6ff'>
<td>2</td><td>Blue</td>
</tr>
<tr bgcolor='#4da6ff'>
<td>5</td><td>Brown</td>
</tr>
<tr bgcolor='#4da6ff'>
<td>6</td><td>DarkOrchid</td>
</tr>
<tr bgcolor='#4da6ff'>
<td>3</td><td>Green</td>
</tr>
<tr bgcolor='#4da6ff'>
<td>1</td><td>Red</td>
</tr>
<tr bgcolor='#4da6ff'>
<td>8</td><td>Silver</td>
</tr>
<tr bgcolor='#4da6ff'>
<td>4</td><td>White</td>
</tr>
</table>
<P>