Send HTML email via C# with SmtpClient

后端 未结 6 707
野趣味
野趣味 2020-11-28 08:43

How do I send an HTML email? I use the code in this answer to send emails with SmtpClient, but they\'re always plain text, so the link in the example message be

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 09:03

    This is what I do:

    MailMessage mail = new MailMessage(from, to, subject, message);
    mail.IsBodyHtml = true;
    SmtpClient client = new SmtpClient("localhost");
    client.Send(mail);
    

    Note that I set the mail message html to true: mail.IsBodyHtml = true;

提交回复
热议问题