【问题标题】:How to apply Bootstrap style to email body如何将 Bootstrap 样式应用于电子邮件正文
【发布时间】:2016-01-22 20:32:24
【问题描述】:

我的 .net MVC 应用程序具有向客户发送电子邮件的逻辑,下面是发送电子邮件的代码。

  string strBody = @"<!DOCTYPE html><html lang='en'><head><title>Ticket Application</title><meta charset='utf-8' /><script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script><link rel='stylesheet' type='text/css' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'></head><body><div class='container'><div class='row'><table class='table-condensed table-responsive'><thead><tr><th></th><th></th></tr></thead><tbody><tr class='danger'><td><label>Title</label></td><td>{title}</td></tr><tr class='active'><td><label>Description</label></td><td>{description}</td></tr><tr><td><label>Project</label></td><td>{project}</td></tr><tr><td><label>Priorty</label></td><td>{priorty}</td></tr><tr><td><label>Current Status</label></td><td>{Open}</td></tr></tbody><tfoot></tfoot></table></div></div></body></html>';";

string strToAddress = "test@test.com";

using (SmtpClient client = new   SmtpClient(ConfigurationManager.AppSettings["SMTPHost"],    Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"])))
{
MailMessage message = new    MailMessage(ConfigurationManager.AppSettings["SMTPFromUser"],
                                                  strToAddress,
                                                    //ConfigurationManager.AppSettings["EmailSubject"],
                                                  "Test Subject",
                                                  strBody);
message.IsBodyHtml = true;              
client.EnableSsl = true;
client.Credentials = new             NetworkCredential(ConfigurationManager.AppSettings["SMTPUser"], ConfigurationManager.AppSettings["SMTPPassowrd"]);
client.Send(message);message.Dispose();
client.Dispose();

}

“strBody”变量包含作为邮件正文的 HTML。 在这个 HTML 中,我包含了用于引导 css 和 JS 文件的 CDN。 https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js

但我没有看到将引导样式应用于电子邮件内容。 请让我知道需要做什么才能将引导样式应用于电子邮件内容。

【问题讨论】:

    标签: asp.net-mvc twitter-bootstrap


    【解决方案1】:
    【解决方案2】:

    只有内联 CSS 样式适用于电子邮件中的 HTML。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-02
      • 2017-05-10
      • 1970-01-01
      • 2011-07-29
      • 1970-01-01
      • 2014-10-26
      • 2012-03-03
      • 1970-01-01
      相关资源
      最近更新 更多