我正在使用以下代码让用户向我的电子邮件发送报价.
I am using the following codes for users to send me a quote to my email.
using System.Net.Mail;
MailMessage mail = new MailMessage();
mail.From = new MailAddress(Email.Text);
mail.To.Add("my yahoo email");
mail.Subject = "Requested Quote From my site";
mail.Body = "<br /><b>Primary project type:</b> " + ProjectTypeRadio.SelectedItem.Text + "<br /><b>Interested In:</b> " + InterestedCheck + "<br /><br /><br /><br /><b>PRODUCT DETAILS:</b><hr />" + Electric + HotWater + PoolHeating + SpaceHeating + "<br /> + "<br /><b>Message:</b><br /><hr /><br />" + txtMsg.Text + "<br /><br />";
SmtpClient smtp = new SmtpClient("smtp.mail.yahoo.com");
smtp.Send(mail);
Response.Redirect("Thanks.aspx");
Web.Config
<system.net>
<mailSettings>
<smtp>
<network host="smtp.mail.yahoo.com" port="995" userName="my yahoo email" password="Password" />
</smtp>
</mailSettings>
问题:我正在我的雅虎帐户中接收邮件,但邮件未格式化,而是显示所有 HTML 标签,即
PROBLEM:
I am recieving the mail in my yahoo account but the message is not formated instead its showing all the HTML tags i.e.
谁能检查我的代码并指出我的错误或指导我一个解决方案,这将是一个很大的帮助,谢谢.
Can anyone please check my code and point my mistake or guide me a solution, it will be a big favor, thanks.
可以设置mail.IsBodyHTML = true
此外,根据您发送的内容,您可能希望使用 AlternateViews 发送纯文本和 text/html 变体.
Also, depending on what you're sending you may want to use AlternateViews to send both plain text and text/html variations.
这篇关于在 C# 中为邮件编译 HTML 正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!