将 <Table> 插入电子邮件时出错

Error Inserting <Table> into Email

我正在尝试在电子邮件中插入 table。我在 6 行代码上出现以下错误(从 "body" 开始,结束 onavgErrorOutStDev += "/table")。错误是:

"The left-hand side of an assignment must be a variable, property or indexer".

<table> 开始是在电子邮件 created/sent 之前执行的方法。我该如何修复错误?

MailMessage errorOutStanDev = new MailMessage();
        errorOutStanDev.IsBodyHtml = true;
        SmtpClient SmtpServerThree = new SmtpClient("smtp.xxxx.xxx");
        errorOutStanDev.From = new 
System.Net.Mail.MailAddress("PerformanceUpdate@xxx.xxx");
        errorOutStanDev.To.Add(new 
System.Net.Mail.MailAddress("xxxxxx@xxxx.xxx"));
        string htmlBody = "<body>" +
                          "<p><b> The following errors have occurred more 
 often than others</b></p>" +
                          avgErrorOutStDev += "<tr>" +
                          avgErrorOutStDev += "<td>" + sitename + "</td>"+ 
                          avgErrorOutStDev += "<td>" + avg + "</td>" +
                          avgErrorOutStDev += "</tr>" +
                          avgErrorOutStDev += "</table>" +
                          "</body>";

构建主体时使用 StringBuilder。代码看起来干净多了。这应该有效。

    string avgErrorOutStDev = string.Empty;
                avgErrorOutStDev += "<tr>";
                avgErrorOutStDev += "<td>" + sitename + "</td>";
                avgErrorOutStDev += "<td>" + avg + "</td>";
                avgErrorOutStDev += "</tr>";
                avgErrorOutStDev += "</table>";

                StringBuilder htmlBody = new StringBuilder();
                htmlBody.AppendLine("<body>");
                htmlBody.AppendLine("<p><b> The following errors have occurred more often than others </ b ></ p >");
                htmlBody.AppendLine(avgErrorOutStDev);
                htmlBody.AppendLine("</ body >");

                htmlBody.ToString();