jteixeira Posted March 30, 2007 Share Posted March 30, 2007 hi, I am devoloping, a web page and I have in a form a gridview with data, and I want to know how I do to sent by email the gridview data when i click in the button. I am workin in visual web developer in C#. I have this: protected void Button3_Click(object sender, EventArgs e) { MailMessage msg = new MailMessage(); msg.From = new MailAddress("xxxx@xxxx.com", "Gestor"); msg.To.Add(new MailAddress("xxxx@xxxx.com","Cliente")); msg.Subject = TextBox1.Text; msg.Body = GetGridHtml(); msg.IsBodyHtml = true; msg.Priority = MailPriority.High; SmtpClient c = new SmtpClient("hotmail.com"); c.Send(msg); } private string GetGridHtml() { GridView1.DataSource = ObjectDataSource1.Select(); ObjectDataSource1.DataBind(); StringWriter writer = new StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(writer); GridView1.RenderControl(htmlWriter); return writer.ToString(); } Anyone can help me?sorry my inglish. Link to comment Share on other sites More sharing options...
jesh Posted March 30, 2007 Share Posted March 30, 2007 I've never attempted to send mail from .NET using hotmail or any of the other free, web-based email providers but I found this link that may explain how to do it with GMail:http://www.andreas-kraus.net/blog/aspnet-2...ail-with-gmail/ 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