C# 在asp.net中将Listview中生成的行解析为html页面格式的电子邮件

C# 在asp.net中将Listview中生成的行解析为html页面格式的电子邮件,c#,asp.net,email,listview,C#,Asp.net,Email,Listview,我想向客户发送电子邮件,告知从数据库生成的listview行。我已经创建了发送电子邮件的html页面&我想在其中放置一个表,在其中显示listview行。我在网上看到一篇帖子。但在这里,他们并没有创建单独的html页面。因为我有其他动态信息要发送到该电子邮件中,所以可以使用html页面和解析该表下的listview行 目前我正在使用这个代码 try { StreamReader reader = new StreamReader(Server.MapPath("/order-cancel

我想向客户发送电子邮件,告知从数据库生成的listview行。我已经创建了发送电子邮件的html页面&我想在其中放置一个表,在其中显示listview行。我在网上看到一篇帖子。但在这里,他们并没有创建单独的html页面。因为我有其他动态信息要发送到该电子邮件中,所以可以使用html页面和解析该表下的listview行

目前我正在使用这个代码

try {
    StreamReader reader = new StreamReader(Server.MapPath("/order-cancel-format.html"));
    string readFile = reader.ReadToEnd();
    string myString = "";
    myString = readFile;
    myString = myString.Replace("$$firstName$$", userName.Text);
    myString = myString.Replace("$$orderIDCode$$", myOrderID.Text);
    MailMessage mail = new MailMessage();
    SmtpClient SmtpServer = new SmtpClient();
    mail.To.Add(userEmail.Text);
    mail.From = new MailAddress("info@foxboxretail.com");
    mail.Subject = "Cancellation of your Order " + myOrderID.Text + "";
    mail.Body = myString.ToString;
    mail.IsBodyHtml = true;
    SmtpServer.Port = 25;
    SmtpServer.Credentials = new System.Net.NetworkCredential("info@domain.com", "password123");
    SmtpServer.Host = "relay-hosting.secureserver.net";
    SmtpServer.EnableSsl = false;
    SmtpServer.Send(mail);
} catch (Exception ex) {
    Response.Write(ex);
}

与其发送gridview,不如发送datatable?那就容易了。不管怎样,您都在将数据表绑定到网格。我说得对吗?@kumarch1是的,对。那么你可以试试这样的东西。参考链接@kumarch1你是说我需要在代码隐藏中编写html代码?是的。这是唯一的办法。没有其他选择