【发布时间】:2021-11-05 09:29:30
【问题描述】:
以下代码在正文电子邮件中发送 gridview。如何添加图表以显示在正文电子邮件中(不是通过附件)。 我尝试使用“AlternateViews.Add”,但 gridview 消失了。
protected void btn_sendmail_Click(object sender, EventArgs e)
{
try
{
MailMessage mm = new MailMessage();
mm.From = new MailAddress("Ttest@xxx.com", "website (Do not reply)");
mm.To.Add(ConfigurationManager.AppSettings["MailDailyReport"]);
mm.Subject = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");
mm.Body = "<span style='font-family:Calibri;font-size:12pt;'>Dear all, <br/>";
mm.Body += "Please find the details of daily production report for " + DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy") + " in picture below.";
mm.Body += "<br/>";
mm.Body += " ";
mm.Body += GetGridviewData(gvProdReport);
mm.Body += "Group by";
mm.Body += GetSubGridviewData(gvSubTotal);
mm.Body += "<br/>";
mm.Body += "If you have any questions or comments do feel free to reply all.";
mm.Body += "</splan>";
mm.IsBodyHtml = true;
SmtpClient SmtpServer = new SmtpClient(ConfigurationManager.AppSettings["MailServer"]);
SmtpServer.Credentials = new System.Net.NetworkCredential("Ttest@xxx.com", "Call5191");
SmtpServer.Send(mm);
lbl_result.Text = "Send complete!";
}
catch (Exception ex)
{
lbl_result.Text = "Send incomplete! message :" + ex.ToString();
lbl_result.ForeColor = Color.Red;
}
}
【问题讨论】:
-
您能否提供更多信息,说明哪些方法无效以及您尝试过哪些方法