This blog will explain how to create an HTML Table in Email body dynamically in C#.
C# Code
- string textBody = "<table border="+1+" cellpadding="+0+" cellspacing="+0+" width = "+400+"><tr bgcolor='#4da6ff'><td><b>Inventory Item</b></td> <td> <b> Required Qunatity </b> </td></tr>";
-
- textBody += "</table>";
- MailMessage mail = new MailMessage();
- System.Net.Mail.SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
-
- mail.From = new MailAddress("from_email Id");
- mail.To.Add("to_emild id");
- mail.Subject = "Test Mail";
- mail.Body = textBody;
- mail.IsBodyHtml = true;
- SmtpServer.Port = 587;
- SmtpServer.Credentials = new System.Net.NetworkCredential("email", "Password");
- SmtpServer.EnableSsl = true;
-
- SmtpServer.Send(mail);
Mandatory
Without the above mentioned code, there is no way to get table in email body.