Send html generated page to a string instead to browser

  • Thread starter Thread starter NWx
  • Start date Start date
N

NWx

Hi,

I want to send html mail from my asp net application.
But I'd like to let aspnet generate the HTML mailbody for me instead of
creating it myself.

So, is there any way to "capture" the result of a ASPX page to a string
variable instead of sending it to the client browser?

I want to assign this string to mailbody then, to send it by mail.
Also, how can I force the aspx to include full URL to resource instead of
just relative path?

Thank you
 
You can use the System.Net.WebClient class to post to the page and get the
results:

WebClient client = new WebClient();
client.Headers.Add(...);
Stream output = client.OpenRead(...);
StreamReader outputReader = new StreamReader(output);
string outputString = outputReader.ReadToEnd();
// use this string to create your email
 
Thank you for your answer.
Best regards

Chris Jackson said:
You can use the System.Net.WebClient class to post to the page and get the
results:

WebClient client = new WebClient();
client.Headers.Add(...);
Stream output = client.OpenRead(...);
StreamReader outputReader = new StreamReader(output);
string outputString = outputReader.ReadToEnd();
// use this string to create your email


--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
 
Back
Top