Hi,
I need to send gridview data as an email where i am able to bind the gridview header values but i'm facing the problem on binding the content of gridview.Please go through the below code and find me the solution.
private StringBuilder htmlMessageBody(GridView dg)
{
StringBuilder strB = new StringBuilder();
strB.AppendLine("<html><body><center><" +
"table border='1' cellpadding='0' cellspacing='0'>");
strB.AppendLine("<tr>");
for (int i = 0; i < dg.Columns.Count; i++)
{
strB.AppendLine("<td align='center' valign='middle'>" +
dg.Columns.HeaderText + "</td>");
}
strB.AppendLine("<tr>");
for (int i = 0; i < dg.Rows.Count; i++)
{
strB.AppendLine("<tr>");
for (int j = 0; j < dg.Columns.Count; j++)
{
strB.AppendLine("<td align='center' valign='middle'>" +
dg.Columns[j].ToString()+ "</td>");
}
strB.AppendLine("</tr>");
}
strB.AppendLine("</table></center></body></html>");
return strB;
}
My Mailing class file here i'm calling the htmlMessageBodyfunction where i'm passing my gridview as a body of mail message
ml.mymail(allMails,htmlMessageBody(grdContctDetails).ToString() ,"Hello");
Here i'm getting an Email like this Address DOB Phone Qualification Company City State Instead of
Address DOB Phone Qualification Company City State
no-5 tamil nadu 1/1/9180 080-2223456788 B.E nfosys Mumbai Maharashtra here i'm unable to get these values no5-tamilnadu,11/9180....
Join Hands Change lives
Thanks & Regards
Straight Edge Society