jteixeira Posted April 9, 2007 Share Posted April 9, 2007 Hi , I'am trying to send a gridview data by email, but i don't no why to do. I'am using visual web developer in c# Someone can help me? It is very important Link to comment Share on other sites More sharing options...
jteixeira Posted April 12, 2007 Author Share Posted April 12, 2007 I search and find, for all who want know this: using System.Net.Mail;protected void Button1_Click(object sender, EventArgs e) { MailMessage msg = new MailMessage(); msg.From = new MailAddress("xxxxx@xxxxx.com, "name"); msg.To.Add(new MailAddress("xxxxx@xxxxx.com", "name")); msg.Subject = "text"; msg.Body = GetGridHtml(); msg.IsBodyHtml = true; msg.Priority = MailPriority.High; SmtpClient c = new SmtpClient("mx.ptmail.sapo.pt"); c.Send(msg); Response.Write("send sucessful!"); } private string GetGridHtml() { GridView gv = new GridView(); gv.DataSource = ObjectDataSource1.Select(); gv.DataBind(); StringWriter writer = new StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); gv.RenderControl(htmlWriter); return writer.ToString(); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now