title: Add different table in one email
body: <p>I have a system that automatically invoke an email. 
  What I want to do is when the system trap that today is FRIDAY I want to create a 
  different tables in one email.</p>
  
  <p>As of now my system can invoke an email per day.</p>
  
  <p>Here is what I want to achieve.</p>
  
  <p>Example today is Monday The system will send :</p>
  
  <p><em>"List of expiry product for Tuesday Table" (Same with tuesday to thursday)</em></p>
  
  <p><em>Tuesday - "List of expiry product for Wednesday"</em></p>
  
  <p><em>Wednesday -  "List of expiry product for Thursday"</em></p>
  
  <p><em>Thursday - "List of expiry product for Friday"</em></p>
  
  <p>and if the day is FRIDAY I want to email the list of expiry products for 3days Like this :</p>
  
  <p>Below is the list of products that will expire on Saturday to Monday.
  (Each day comes with different table in one email only) Like this :</p>
  
  <p><em>Below is the list of expiry product for<a href="https://i.stack.imgur.com/mbXqV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mbXqV.jpg" alt="table"></a> .</em></p>
  
  <p>As of now my system can send email per day. I don't know how I might going to achieve
  the output for friday email blast. </p>
  
  <p><strong>Here is what I have so far :</strong></p>
  
  <p>I have created two different sub class. My one subclass is an email setup for Monday to Thursday
  and the other one is an email setup for Friday which compose of 3days different tables.</p>
  
  <pre><code>Sub EmailMondayThursday
  
  Dim ds As New DataSet
      Dim cmd As New SqlCommand
      Dim dt As New DataTable
      Dim adp As New SqlDataAdapter
      Dim c As New SqlConnection("myconnectionhere")
      Dim emaildate As String
  emaildate = DateTime.Today.AddDays(1).Date.ToString("D")
      cmd.Connection = c
      cmd.CommandText = "sp_progspot_monitor"
      cmd.Parameters.AddWithValue("@prdname", "%")
      cmd.Parameters.AddWithValue("@prdcde", "%")
      cmd.Parameters.AddWithValue("@prdfrdate", Date.Today.AddDays(1))
      cmd.Parameters.AddWithValue("@prdtodate", Date.Today.AddDays(1))
      cmd.Parameters.AddWithValue("@cost", "%")
      cmd.CommandType = CommandType.StoredProcedure
      adp.SelectCommand = cmd
      adp.Fill(ds)
  
  Dim dv As New DataView(ds.Tables(0))
      Dim dvfilter As DataTable = dv.ToTable(True, {"teledte"})
      Dim dt2 As New DataTable
      For Each dtrow As DataRow In dvfilter.Rows
          dv.RowFilter = "Total_Load &lt; Potential_Load"
          dt2 = dv.ToTable(False, {"Date", "Prouduct Name", "Product Code",  "Total Sales"})
      Next
  
  Dim builder As New StringBuilder
  builder.Append("&lt;!DOCTYPE html&gt;&lt;html&gt;")
  builder.Append("&lt;head&gt;&lt;/head&gt;") 
  builder.Append("&lt;table&gt;")   
  builder.Append("&lt;tr&gt;")
  builder.Append("&lt;th&gt;Date&lt;/th&gt;")
  builder.Append("&lt;th&gt;Product Name&lt;/th&gt;")
      builder.Append("&lt;th&gt;Product Code&lt;/th&gt;")
      builder.Append("&lt;th&gt;Total Sales&lt;/th&gt;")
  builder.Append("&lt;tr&gt;")  
  builder.Append("&lt;/table&gt;")  
  builder.Append("&lt;/html&gt;")
   For Each row As DataRow In dt2.Rows
          builder.Append("&lt;tr&gt;")
          Dim i As Integer
          i = 1
          For Each col As DataColumn In dt2.Columns
              builder.Append("&lt;td class=""" &amp; i &amp; """&gt;" &amp; row(col).ToString + " " &amp; "&lt;/td&gt;")
              i = i + 1
          Next
          builder.Append("&lt;/tr&gt;")
          builder.AppendLine()
      Next
  builder.Append("&lt;/tbody&gt;")
      builder.Append("&lt;/table&gt;")
  setemail("myemail@yahoo.com", "pass", builder.ToString)
  </code></pre>
  
  <p>End SUb</p>
  
  <p><strong>And here is my Sub class for FridayEmail</strong></p>
  
  <pre><code>Dim ds As New DataSet
          Dim cmd As New SqlCommand
          Dim dt As New DataTable
          Dim adp As New SqlDataAdapter
          Dim c As New SqlConnection("myconnectionhere")
          Dim emaildtefrm As String
      dim emaildteto as String
      emaildtefrm = DateTime.Today.AddDays(1).Date.ToString("D")
      emaildteto = DateTime.Today.AddDays(3).Date.ToString("D")        
      cmd.Connection = c
          cmd.CommandText = "sp_progspot_monitor"
          cmd.Parameters.AddWithValue("@prdname", "%")
          cmd.Parameters.AddWithValue("@prdcde", "%")
          cmd.Parameters.AddWithValue("@prdfrdate", Date.Today.AddDays(1))
          cmd.Parameters.AddWithValue("@prdtodate", Date.Today.AddDays(3))
          cmd.Parameters.AddWithValue("@cost", "%")
          cmd.CommandType = CommandType.StoredProcedure
          adp.SelectCommand = cmd
          adp.Fill(ds)
  
      Dim dv As New DataView(ds.Tables(0))
          Dim dvfilter As DataTable = dv.ToTable(True, {"teledte"})
          Dim dt2 As New DataTable
          For Each dtrow As DataRow In dvfilter.Rows
              dv.RowFilter = "Total_Load &lt; Potential_Load"
              dt2 = dv.ToTable(False, {"Date", "Prouduct Name", "Product Code",  "Total Sales"})
          Next
  
      Dim builder As New StringBuilder
      builder.Append("&lt;!DOCTYPE html&gt;&lt;html&gt;")
      builder.Append("&lt;head&gt;&lt;/head&gt;") 
      builder.Append("&lt;body&gt;")
      builder.Append("&lt;p&gt; Below is the list of expiry product from " &amp; emaildtefrm &amp; "to" &amp; emaildteto &amp;  "&lt;/p&gt;")
      builder.Append("&lt;table&gt;")   
      builder.Append("&lt;tr&gt;")
      builder.Append("&lt;th&gt;Date&lt;/th&gt;")
      builder.Append("&lt;th&gt;Product Name&lt;/th&gt;")
          builder.Append("&lt;th&gt;Product Code&lt;/th&gt;")
          builder.Append("&lt;th&gt;Total Sales&lt;/th&gt;")
      builder.Append("&lt;tr&gt;")  
      builder.Append("&lt;/table&gt;")  
      builder.Append("&lt;/html&gt;")
       For Each row As DataRow In dt2.Rows
              builder.Append("&lt;tr&gt;")
              Dim i As Integer
              i = 1
              For Each col As DataColumn In dt2.Columns
                  builder.Append("&lt;td class=""" &amp; i &amp; """&gt;" &amp; row(col).ToString + " " &amp; "&lt;/td&gt;")
                  i = i + 1
              Next
              builder.Append("&lt;/tr&gt;")
              builder.AppendLine()
          Next
      builder.Append("&lt;/tbody&gt;")
          builder.Append("&lt;/table&gt;")
      setemail("myemail@yahoo.com", "pass", builder.ToString)
  </code></pre>
  
  <p>This code is for trapping the day today so that when the system know the day it will conditionally send an email based to the condition.</p>
  
  <p>Protected Sub ImageButton1_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click</p>
  
  <pre><code>    Dim daytoday As String = DateTime.Today.DayOfWeek
  
      If daytoday.ToString = "1" or Then
          EmailMondayThursday()
      ElseIf daytoday.ToString = "4" Then
          MsgBox("Thursday")
  
      ElseIf daytoday .ToString = "5" Then
      ProgSpotEmailFriday()
      End If
  
  End Sub
  </code></pre>
  
  <p>The problem with the Subclass FridayEmail the output is like this:
  <a href="https://i.stack.imgur.com/h6ZEV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h6ZEV.jpg" alt="enter image description here"></a></p>
  
  <p>What i want to achieve is something like below
  <a href="https://i.stack.imgur.com/aFLZo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aFLZo.jpg" alt="enter image description here"></a></p>