in my wpf application i need to send an email and the body of the list i need to send a list of items.Now everything works fine except that the body is not rendred to the format that i wrote in my code. This is the function that send an email:
public static void CreateTimeoutTestMessage(string ParentAdress, List<KidHistory> list,Parent p,Enfant e)
{
var fromAddress = new MailAddress("famissima.mic@gmail.com", "famissima.mic");
var toAddress = new MailAddress(ParentAdress);
const string fromPassword = "xxxxxxxxxx";
const string subject = "Subject";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Timeout = 20000,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
var message = new MailMessage(fromAddress, toAddress);
message.Subject = subject;
if (p.Civilite == "Mr")
message.Body += "Bonjour Mr. " + " " + p.Nom + " " + p.Prenom + " ,l'historique de navigation de votre enfant " + e.pseudo + " est: ";
else
message.Body += "Bonjour M. " + " " + p.Nom + " " + p.Prenom + " ,l'historique de navigation de votre enfant " + e.pseudo + " est: ";
message.Body += "<table width='100%' style='border:Solid 1px Black;'>";
foreach (var item in list)
{
message.Body += "<tr>";
message.Body += "<td stlye='color:blue;'>" + item.url + "</td>" + "<td stlye='color:blue;'>" + item.StartDate + "</td>" + "<td stlye='color:blue;'>" + item.FinishDate + "</td>";
message.Body += "</tr>";
}
message.Body += "</table>";
smtp.Send(message);
}
and this is the output(the received mail):