如何添加html数据高图以发送电子邮件

时间:2017-10-01 09:48:44

标签: javascript c# highstock

我想通过电子邮件发送html,html显示在电子邮件中,但图表(highcharts)不显示css: 它的外观如下:

PassFailBlockedNo RunUnder DebugPass Rate%11.8.50.339911.8.50.339411.8.50.3393v211.8.50.338711.8.50.338211.8.50.837311.8.50.836811.8.50.836011.8.50.835411.8.50.835111.8.50.8344v211.8.50.83380300150450600010025507511.8.50.8354●通过:474●失败:0●被阻止:0●无运行:0●调试下:0●通过率%:100 ...

是JS代码:

function Send_Mail() {
    var html = "";
    html += "<html><head><style>";
    $.get("Highstock-5.0.14/code/css/highcharts.css").done(function(result) {
        html += result;
        $.get("Content/ReportStyle.css").done(function(result) {
            html += result + "</style></head>";
            $(".ToMail").each(function() {
                html += $(this).html();
            });
            html += "</html>";
            return $.ajax({
                type: "POST",
                url: "ExecutionReportService.asmx/send_mail",
                data: JSON.stringify({ body: html }),
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            });
        });
    });
}

C#代码:

[WebMethod]
public void send_mail(string body)
{
    var smtp = new SmtpClient("smtp.xxx.com");
    var mailMsg = new MailMessage
    {
        IsBodyHtml = true,
        From = new MailAddress("xxxx@gmail.com"),
        Subject = "Email subject",
        Body = body
    };


    mailMsg.To.Add("xxxx@gmail.com");
    smtp.Send(mailMsg);
}

0 个答案:

没有答案