Hi there,
I have an email which has the body as an HTML table and I need to read every row and output the values as an XML.
Any suggestions on how to achieve this ?
Regards,
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Oct 23, 2010, 2:53 PM
I am assuming that you have read my article, especially the part about HtmlDocument and HTMLDocument.
First add a reference to "Microsoft HTML Object Library"; it is a COM Object, not in the .Net library. Then the following console program shows how to get HTML into an HTML document.
Schuster EfigenioPosted Oct 25, 2010, 10:14 AM
I have found an HTML agility pack and the does pretty much everything you would want to with HTML.
just if you need this for future reference.
regards,
Schuster EfigenioPosted Oct 25, 2010, 7:26 AM
Yes, it is frustrating I want to basically get all the table row values in Document.body.innerHTML and store them in a string array.
I have spend some time trying several ways but to no end.
thanks for your help.
I will try suthish's suggestion and links and see if i can solve my issue.
Suthish NairPosted Oct 25, 2010, 4:08 AM
Sam HobbsPosted Oct 24, 2010, 10:50 PM
Suthish NairPosted Oct 24, 2010, 1:27 PM
using (StreamReader reader = new StreamReader(Server.MapPath("email.html"))){
String line = String.Empty;
while ((line=reader.ReadLine()) != null)
{
refer for xml conversion...
http://www.ibm.com/developerworks/library/x-tiptidy.html
http://www.example-code.com/csharp/html2xml.asp
Schuster EfigenioPosted Oct 24, 2010, 5:45 AM
Got a bit further. I have now got the email in HTML but having troubles reading all the data.
I have attached the HTML page.
Schuster EfigenioPosted Oct 23, 2010, 1:02 PM
Let me explain further, when I read email body I need to cast it in HTML or a way of obtaining the HTML that I see when viewing the source in outlook. At present I am only able to store that contents in a string variable but I require the contents in its HTML form.
Hope that helps.
Sam HobbsPosted Oct 23, 2010, 6:25 AM
If I misunderstand what you mean by "reading the body of the email in its HTML form" then you need to be more clear; there are multiple possible interpretations.
Schuster EfigenioPosted Oct 23, 2010, 6:11 AM
Sam HobbsPosted Oct 23, 2010, 6:00 AM
Another possibility would be to copy the table to the clipboard and then paste the table into Excel or Access or a similar application. That might not work but it will be relatively easy to try.