Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have dataset containing data in the form of a table and i want that table should be in html file so can i mail that text file to the client please help
Posted
Comments
Schatak 10-May-14 6:42am    
you means you want to export data in text file?
Hadees 10-May-14 7:07am    
Yes

StringBuilder SB = new StringBuilder();
                    StringWriter SW = new StringWriter(SB);
                    HtmlTextWriter htmlTW = new HtmlTextWriter(SW);
                    pnlDetails.RenderControl(htmlTW);
 
                    
                    string body=SB.ToString();


// Create a writer and open the file:
StreamWriter log;

if (!File.Exists("logfile.txt"))
{
  log = new StreamWriter("logfile.txt");
}
else
{
  log = File.AppendText("logfile.txt");
}

// Write to the file:
log.WriteLine(body);
log.WriteLine();

// Close the stream:
log.Close();
 
Share this answer
 
Comments
JayantaChatterjee 10-May-14 10:25am    
My vote of 5...
If you want to send mail with table data then you can do it like this.

1) bind table to gridview
2) put gridview in panel control
3) and you can render your panel as html control ans send mail.

StringBuilder SB = new StringBuilder();
                    StringWriter SW = new StringWriter(SB);
                    HtmlTextWriter htmlTW = new HtmlTextWriter(SW);
                    pnlDetails.RenderControl(htmlTW);

                    
                    string body=SB.ToString();


replace your panel id to pnlDetails
now you can send your body in mail
 
Share this answer
 
Comments
Hadees 10-May-14 7:11am    
Thanks for you reply dear...<br>
previously i was exported dataset into excel file now instead of excel file i need to store in .txt file and want to save this file in specific folder of project

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900