TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ankit Agarwal
NA
379
253k
How to send gridview in email body using c# asp.net?
Feb 6 2014 1:18 AM
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
Reply
Answers (
1
)
Retain dropdown values in gridview
treeview in visual studio 2012