我对 StringBuilder 类的 AppendFormat 方法有疑问。我正在创建表格并在字符串构建器对象中附加数据以将其作为邮件发送,但是当我看到我发送的邮件时,它看起来不像表格,它的标题和相应的内容被错放。我希望表格由 Lines 分隔,因为它通常存在于 microsoft word 的表格中。我怎样才能实现它..我正在使用以下代码: Body is a StringBuilder Object
if ( dic1 != null )
{
//Body.AppendFormat("Client: " + cl + " Success. " + dic1.Count + " :");
Body.AppendFormat("<br/><table>");
Body.AppendFormat("<h1><tr><td>#</td><td>Files Name</td></tr></h1>");
int count = 1;
foreach ((KeyValuePair<string, string> pair in dic1)
{
if (!String.IsNullOrEmpty(pair.Key))
{
Body.AppendFormat("<tr><td>"+count.ToString()+"</td><td>" + pair.Key + "</td><td> " + pair.Value + "</td></tr>");
count++;
//Body.Append( );
}
}
Body.AppendFormat("</table>");
以下是我在收件箱中收到的输出。
# File Name Error
1 txt1.txt Loading File 'txt1.txt' failed: The specified File already exists in the system
2 txt2.txt Loading File 'txt2.txt' failed: The specified File already exists in the system
3 txt3.txt Loading File 'txt3.txt' failed: The specified File already exists in the system