Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
How to send gridview in email body using c# asp.net?
Ankit Agarwal
10y
8.7k
1
Reply
Hello,
How to send gridview in email body using c# asp.net?
I am using this code for send gridview in email body, but i have a problem for this,
One image also in my gridview, my gridview sending but image it's not sending and grid formatting also it's not sending, only simple grid sending and delete button also sending.
protected void SendEmail(object sender, EventArgs e)
{
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
GridView1.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
MailMessage mm = new MailMessage("
[email protected]
", "
[email protected]
");
mm.Subject = "GridView Email";
mm.Body = "GridView: <hr />
" + sw.ToString(); ;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = "
[email protected]
";
NetworkCred.Password = "
";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
}
}
}
My gridview it's not sending in proper format with image.
How can we send my Gridview in proper format?
Please help me.
Thanks in Advance
Ankit Agarwal
Website Developer
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Retain dropdown values in gridview
treeview in visual studio 2012