通过C#与SmtpClient发送HTML电子邮件 [英] Send HTML email via C# with SmtpClient

查看:478
本文介绍了通过C#与SmtpClient发送HTML电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何发送HTML电子邮件?我用的是code在<一个href=\"http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c/707892#707892\">this回答发送电子邮件与 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="http://SiteName.com/a?key=1234">http://SiteName.com/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电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆