asp.net wih在gridview中发送电子邮件 [英] asp.net wih send email in gridview
本文介绍了asp.net wih在gridview中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have gridview having the table name tblemployee coulmn name empid , fisrtname , lastname , Email
now i want to send the gridview as attachment to all the email id that exist in the tblemployee how can i do so
推荐答案
您可以将Gridview转换为html或excel,然后通过电子邮件发送此文件。
例如
You can convert the Gridview to html or excel then send this file via email.
For e.g.
private string GridViewToHtml(GridView gv)
{
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
gv.RenderControl(hw);
return sb.ToString();
}
protected void SendMailButton_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.Body = GridViewToHtml(GridView1);
mail.IsBodyHtml = true;
//Send email
}
这篇关于asp.net wih在gridview中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文