473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Send html generated page to a string instead to browser

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
Nov 18 '05 #1
2 1528
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
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"NWx" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2
NWx
Thank you for your answer.
Best regards

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
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
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"NWx" <te**@test.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

72
by: Mel | last post by:
Are we going backwards ? (please excuse my spelling...) In my opinion an absolute YES ! Take a look at what we are doing ! we create TAGS, things like <H1> etc. and although there are tools...
4
by: Mark J. McGinty | last post by:
Greets, Part of the content of one of our web pages uses wingdings and Chr(239) through Chr(242) (which are little arrow outlines, though that's not really important.) It worked just fine in...
7
by: joseph.inglis | last post by:
I have a web browser object on a form which I have set to edit mode and use the UCOMIConnectionPointContainer interface to hook in and catch events. All working sweetly. Except there...
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
59
by: Lennart Björk | last post by:
Hi All, I have a tiny program: <!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>MyTitle</title> <meta...
6
by: john | last post by:
The standard method to transmit a file from an aspx page to a browser is to stream the file to the response then end the response. The HTML code generated by the aspx page is discarded, and the...
5
by: Jesper | last post by:
Hi, Is there an alternative to an URI location when loading html into a webBrowser control. I have some html generated in a string. I would like to skip saving the string to a file on disk...
7
by: Xah Lee | last post by:
Summary: when encountering ex as a unit in css, FireFox (and iCab) did not take into account the font-family. Detail: http://xahlee.org/js/ff_pre_ex.html Xah xah@xahlee.org ∑...
2
by: ste-m | last post by:
Hi there, I was wanting to calculate how long my web pages take to load, and to insert this time into my HTML source code (not visible from the browser, but only in source view) as a HTML...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.