Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
How to send gridview in email body using c# asp.net?
Ankit Agarwal
Feb 6 2014 1:18 AM
8.7k
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Retain dropdown values in gridview
treeview in visual studio 2012