title: How can I generate a GridView or DataGrid using only C# in a Command Line application?
body: <p>I am adding on to a command line program that really just runs automatically on a server, sends a daily email with a transaction total every day.</p>
  
  <p>What I would like to add to the email is a DataGrid or GridView like in ASP.NET, displaying specific company names and their totals (rather than just a total number for everyone).</p>
  
  <p>I think I can figure how to get the data from the db and use it for this but I'm not sure how to put a Grid together for the email body. I know I could put the HTML in the email body for a table but how could I populate it dynamically with information?</p>
  
  <p>I've seen tutorials with web applications that will do this from an event handler, basically sending the same GridView from a web form but I would like to do this from a basic command line application alone. </p>
  
  <p>Could someone point me in the right direction?</p>
  
  <pre><code>var body = "Good Morning --&lt;br/&gt;&lt;br/&gt;Yesterday, " +
      DateTime.Now.AddDays(-1).ToString("dddd") + " " +
      DateTime.Now.AddDays(-1).ToShortDateString() +
      " there were " + count.ToString(CultureInfo.InvariantCulture) +
      " payments processed with a total of " +
      paymentAmount + "&lt;br /&gt;&lt;br /&gt;" + 
      "Please visit &lt;a href=\"" + url + "?date=" +
      DateTime.Now.AddDays(-1).ToShortDateString().Replace("/", "-") +
      "\" title=\"Click here to view the transactions.\"&gt;" + url +
      "&lt;/a&gt; to view the transactions." + "&lt;br /&gt;&lt;br /&gt;Company Totals:&lt;br /&gt;";
  
  // create and populate a datagrid programatically for insertion into our email
  body += "Grid goes here";
  </code></pre>