如何在邮件正文表中打印以下数据集

时间:2019-02-05 05:12:11

标签: c# html

我具有以下用于生成HTML电子邮件的代码:

reader = cmd.ExecuteReader();
while (reader.Read())
{

     mailbody +=
        "<tr>" +
        "<td>" + reader["DevName"].ToString() + "</td>" +
        "<td>" + reader["DevId"].ToString() + "</td>" +
        "<td>" + reader["LocationID"].ToString() + "</td>" +
        //"<td>" + reader["LocationName"].ToString() + "</td>" +
        "<td>" + reader["SubLocationID"].ToString() + "</td>" +
        "<td>" + reader["IPV6"].ToString() + "</td>" +
        "<td>" + reader["LastConnTime"].ToString() + "</td>" +
        "<td>" + reader["LastDisconnTime"].ToString() + "</td>" +
        "<td>" + reader["Online"].ToString() + "</td>" +
        "<td>" + reader["HardwareSerialNumber"].ToString() + "</td>" +
        "<td>" + reader["ServiceProviderID"].ToString() + "</td>" +
        "<td>" + reader["DateLastModified"].ToString() + "</td>" +
        "<tr>";
}

if (mailbody !=string.Empty)
{
    mailbody += "</table>";
    string bodyStructure = "<html><head></head><body>" + @"<table border =""1"" cellpadding=""2"" style=""border=collapse:collapse;""><tr style=""color:white; background-color:SkyBlue; font-wieght:bold;"">" + "<td>DeviceName</td> <td>DeviceID</td>  <td>LocationID</td> <td>LocationName</td>   <td>SubLocationID</td>  <td>IPAddress</td>  <td>LastConnected</td>  <td>LastDisconnected</td> <td>HardwareSerialNumber</td>  <td>DeviceStatus</td> <td>HardwareSerialNumber</td>  <td>ServiceProviderID</td>  <td>LastTransactionSync</td>" + "</tr>" + mailbody + "</body</html>";
    message.IsBodyHtml = true;
    message.Subject = "DeleteDuplicateDevicesReport";
    message.Body = bodyStructure;
    smtp.Send(message);
}

读者将在此处生成表格的每一行,然后合并到我的HTML模板的其余部分中。

这是我收到的电子邮件: enter image description here

为什么我的电子邮件在没有呈现HTML的情况下到达?

0 个答案:

没有答案