내 wpf 응용 프로그램에서 전자 메일을 보내고 목록의 본문을 보내야합니다. 본문이 내 코드에 쓴 형식으로 렌더되지 않은 것을 제외하고는 모든 항목이 올바르게 작동합니다. 이 이메일 전송 기능입니다 :전자 메일로 목록을 보내는 방법은 무엇입니까?
public static void CreateTimeoutTestMessage(string ParentAdress, List<KidHistory> list,Parent p,Enfant e)
{
var fromAddress = new MailAddress("[email protected]", "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);
}
을이 출력 (수신 메일)입니다 : true로 IsBodyHtml
이 메시지 본문에 HTML 태그를 사용할 수 있도록 설정
[HTML 파일을 본문으로 사용하여 이메일 보내기 (C#)] (http://stackoverflow.com/questions/1155797/send-a-email-with-a-html-file-as) -body-c) – nemesv