我有这个任务,我必须从一张桌子和它们的行中取出三列,然后以一种非常整洁的专业方法将它们发送给我的老板。我需要帮助,因为我在下面使用的方法看起来非常荒谬并且没有对齐电子邮件的形式。你们能帮我把它转换成 HTML 和正确的格式,让它看起来很整洁。
static void Main(string[] args)
{
SqlConnection myConnection = new SqlConnection("mydatasourceinfo");
// Connect to the SQL database using a SQL SELECT query to get all
string sqlStr = " select * from thedifference ";
SqlDataAdapter myCommand = new SqlDataAdapter(sqlStr, myConnection);
// Create and fill a DataSet.
DataSet ds = new DataSet();
myCommand.Fill(ds);
DataView source = new DataView(ds.Tables[0]);
SmtpClient smtp = new SmtpClient();
string from = "xxx.com";
string to = "xxx.com";
string subject = "data differences";
string body = "ClientName | Salesdiff | CallsDiff";
foreach (DataRow Row in ds.Tables[0].Rows)
{
body = body + " " + "\n" + Row["clientname"] + " " + " " + Row["salesdiff"] + " " + Row["callsdiff"] + "\n";
}
smtp.Host = "xxx.com";
smtp.Send(from, to, subject, body);
}