Retain CSS format reading a Page
-
I have the following routine: public static string readHtmlPage(string url) { string result; WebRequest request = WebRequest.Create(url); HttpWebResponse response =(HttpWebResponse) request.GetResponse(); Stream dataStream = response.GetResponseStream(); using (StreamReader reader = new StreamReader(dataStream)) { result = reader.ReadToEnd(); reader.Close(); } return result; } I email the "result" as the body of an email message but it is loosing its CSS formating. It seems that CSS is never applied can anybody detect something wrong?
-
I have the following routine: public static string readHtmlPage(string url) { string result; WebRequest request = WebRequest.Create(url); HttpWebResponse response =(HttpWebResponse) request.GetResponse(); Stream dataStream = response.GetResponseStream(); using (StreamReader reader = new StreamReader(dataStream)) { result = reader.ReadToEnd(); reader.Close(); } return result; } I email the "result" as the body of an email message but it is loosing its CSS formating. It seems that CSS is never applied can anybody detect something wrong?
The path to the css is probably relative. As what you have sent in the mail is no longer a page, and has no url, the mail program don't know from where it should load the css. If you specify a complete url for the css file, it has a possibility to work.
--- b { font-weight: normal; }
-
The path to the css is probably relative. As what you have sent in the mail is no longer a page, and has no url, the mail program don't know from where it should load the css. If you specify a complete url for the css file, it has a possibility to work.
--- b { font-weight: normal; }
-
Either change the page, or change the contents once you have read the page. If you have other resources, like images, their addresses have to be changed also. Some resources won't work even if you supply a correct address, like javascript includes. There is no way that you can keep all functionality when you send the code of a page as a mail. A mail program is not a browser, so it will not support everything that a browser does.
--- b { font-weight: normal; }