通过C#与SmtpClient发送HTML电子邮件

编程入门 行业动态 更新时间:2024-10-19 04:30:52
本文介绍了通过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电子邮件

本文发布于:2023-11-17 12:19:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609983.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:电子邮件   SmtpClient   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!