title: send List<> values with Body in mail - SMTP server
body: <p>I have to send mail through <code>SMTP</code> server. I can able to send it with single values. But, I want to send <code>List&lt;&gt;</code> values as message body in table format or some other structure. I include my code following :</p>
  
  <pre><code>MailMessage mailObj = new MailMessage("abc@gmail.com", "xyz@gmail.com", "Reg : send mail",
  "Emp Name :" + "Emp1" + Environment.NewLine + "Date From :   " + Mon + "Date To :   " + Fri);
  SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com", ***);
  SMTPServer.Host = "smtp.gmail.com";
  SMTPServer.EnableSsl = true;
  SMTPServer.Timeout = 200000;
  SMTPServer.Credentials = new System.Net.NetworkCredential("asd@gmail.com", "******");
  SMTPServer.Send(mailObj);
  </code></pre>
  
  <p>I have my list of values as follows :</p>
  
  <pre><code>List&lt;TimesheetValues&gt; mailBody = new SampleDAO().GetDataForMail(dt1, satDate);
  </code></pre>
  
  <p>How can I include this <code>List&lt;&gt;</code> values with body and send?</p>
  
  <p>I try with following :</p>
  
  <pre><code>List&lt;TimesheetValues&gt; Msg = new List&lt;TimesheetValues&gt;(); string strMsg = ""; int n=1;
              foreach(var item in mailBody)
              {
                  strMsg = strMsg + "&lt;table&gt;&lt;tr&gt;&lt;td&gt;" + n + "&lt;/td&gt;&lt;td&gt;" + item.Project_Name + "&lt;/td&gt;&lt;td&gt;" + item.Task_Name + "&lt;/td&gt;&lt;td&gt;" + item.Notes + "&lt;/td&gt;&lt;td&gt;" + item.Hrs_Worked + "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";                
                  n++;
              }
              strMsg = strMsg + "&lt;/br&gt;";
               MailMessage mailObj = new MailMessage("abc123@gmail.com", "xyz123@gmail.com", "Reg : Timesheet",
                  "Emp Name :" + "Emp1" + Environment.NewLine + "Date From :   " + Mon + "Date To :   " + Fri);            
  
               mailObj.Body = "Emp Name : " + "Emp1" + Environment.NewLine + "Date From :   " + Date2 + " Date To :   " + Date6 + Environment.NewLine + strMsg;
  </code></pre>
  
  <p>Now I get all records but i have tr td tags with in records and not display as a table. How can i acheive this ?</p>
  
  <p>can anyone help to overcome this..
  Thanks in advance...</p>