本文介绍了通过C#与SmtpClient发送HTML电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何发送HTML电子邮件?我使用此答案中的代码发送电子邮件与 SmtpClient ,但它们总是纯文本,所以下面的示例消息中的链接不是这样格式。
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 below is not formatted as such.
<p>Welcome to SiteName. To activate your account, visit this URL: <a href="SiteName/a?key=1234">SiteName/a?key=1234</a>.</p>如何在我发送的电子邮件中启用HTML?
How do I enable HTML in the e-mail messages I send?
推荐答案这是我做的:
MailMessage mail = new MailMessage(from, to, subject, message); mail.IsBodyHtml = true; SmtpClient client = new SmtpClient("localhost"); client.Send(mail);请注意,我将邮件消息html设置为true: mail.IsBodyHtml = true;
Note that I set the mail message html to true: mail.IsBodyHtml = true;
更多推荐
通过C#与SmtpClient发送HTML电子邮件
发布评论