Send html generated page to a string instead to browser

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
 
C

Chris Jackson

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
 
N

NWx

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top