Good afternoon everyone.
What I need is to create an HTML table from c #, the data I need I have in a datatable, this in order to send an email from a class and in the body must go a table.
Searching the web I could see that it can be achieved by creating a table in this way but I do not know how to start, as a comment I already have created my class to send the email.
string cuerpo = "";
public DataTable Detalles;
MailMessage mail = new MailMessage();
public void EnviarCorreo(string correo_electronico)
{
int NumeroFilas = Detalles.Rows.Count;
cuerpo = "Se prestaron " + NumeroFilas + " dispositivos a su
nombre";
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new
System.Net.NetworkCredential("Direccion", "password");
SmtpServer.Port = 587;
SmtpServer.Host = "smtp.gmail.com";
SmtpServer.EnableSsl = true;
mail = new MailMessage();
try
{
mail.From = new MailAddress("Direccion de envío", "Prestamo",
System.Text.Encoding.UTF8);
mail.Subject = "Prestamo";
//Justo acá es donde necesito insertar mi tabla
mail.Body = cuerpo;
mail.To.Add(correo_electronico);
SmtpServer.Send(mail);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Thank you in advance.