编译HTML正文邮件在C# [英] Compiling HTML body for mail in c#

查看:169
本文介绍了编译HTML正文邮件在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的codeS为用户报价给我发到我的邮箱。

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中

Web.Config

<system.net>
<mailSettings>
  <smtp>
    <network host="smtp.mail.yahoo.com" port="995" userName="my yahoo email" password="Password" />
  </smtp>
</mailSettings>

问题:
我recieving邮件在我的雅虎帐户,但该消息未格式化,而不是它的显示,即

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.

任何人都可以请检查我的code,并指出我的错误或指导我一个解决方案,这将是一个很大的忙,谢谢。

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 发送纯文本和文本/ HTML的变化。

Also, depending on what you're sending you may want to use AlternateViews to send both plain text and text/html variations.

这篇关于编译HTML正文邮件在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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