【问题标题】:How to send mail using C# with html format [closed]如何使用 C# 以 html 格式发送邮件 [关闭]
【发布时间】:2017-04-13 05:47:09
【问题描述】:

你好,如何在 c# 中从邮件中获取评论和评级?如何为 gmail.i 使用 html 格式。当我点击它时,我已经给出了评论链接,它将我重定向到下一个页面,即 Mail.aspx。那么如何在邮件中发送我的评分和 mail.aspx 文件,我希望我的结果存储在数据库中。

【问题讨论】:

  • 请澄清您的意思?您只想发送带有 html 正文的电子邮件吗?如果是这样,这与评论和评分有什么关系……或 gmail 吗?
  • Stackoverflow 不是您的个人代码编写服务。向我们展示您迄今为止所做的尝试并解释您的问题。

标签: c# asp.net


【解决方案1】:

将 isBodyHtml 设置为 true 允许您在邮件正文中使用 HTML 标记:

SmtpClient sc = new SmtpClient("mail address");
MailMessage msg = null;

try
{
msg = new MailMessage("xxxx@gmail.com",
    "yyyy@gmail.com", "Message from PSSP System",
    "This email sent by the PSSP system<br />" +
    "<b>this is bold text!</b>");

    msg.IsBodyHtml = true;

     sc.Send(msg);
}

catch (Exception ex)
{
    throw ex;
}

finally
{
    if (msg != null)
    {
        msg.Dispose();
    }
}

使用msg.IsBodyHtml = true;

【讨论】:

    猜你喜欢
    • 2016-06-02
    • 2014-02-03
    • 2015-07-19
    • 1970-01-01
    • 1970-01-01
    • 2017-04-20
    • 2011-08-08
    • 1970-01-01
    • 2010-11-26
    相关资源
    最近更新 更多