473,687 Members | 3,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

send entire page by email

Hi,

I have a standard aspx page (form) that contains a few user controls.
Upon form submission the page is validated.
If validation passses then a text based email is sent.
This is all working fine, however what I would like to do is sent the entire
contents of the posted back page as a HTML email.

Is this possible and if so could somebody point me in the right direction to
achieving this.

many thanks in advance.

cheers

martin.

Nov 19 '05 #1
7 2144
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Martin" <ma************ *******@martinz .co.nz> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

I have a standard aspx page (form) that contains a few user controls.
Upon form submission the page is validated.
If validation passses then a text based email is sent.
This is all working fine, however what I would like to do is sent the
entire contents of the posted back page as a HTML email.

Is this possible and if so could somebody point me in the right direction
to achieving this.

many thanks in advance.

cheers

martin.

Nov 19 '05 #2
Actually, emailing the content produced by Page.Render() will do the job if
the page you want to email is the page itself. And it would be a lot
simpler.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> 秎ン
news:up******** *******@TK2MSFT NGP10.phx.gbl い级糶...
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Martin" <ma************ *******@martinz .co.nz> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

I have a standard aspx page (form) that contains a few user controls.
Upon form submission the page is validated.
If validation passses then a text based email is sent.
This is all working fine, however what I would like to do is sent the
entire contents of the posted back page as a HTML email.

Is this possible and if so could somebody point me in the right direction to achieving this.

many thanks in advance.

cheers

martin.


Nov 19 '05 #3
Hi Lau,

I called page.render from a button click on the page.
I used the following code.

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter( sw)
Me.Render(htmlW riter)
I got an error saying "The page can only have one server-side form tag"
I guess the page thinks it is being rendered twice.

do you have any suggestions??

cheers

martin.



"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
Actually, emailing the content produced by Page.Render() will do the job
if
the page you want to email is the page itself. And it would be a lot
simpler.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> 秎ン
news:up******** *******@TK2MSFT NGP10.phx.gbl い级糶...
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Martin" <ma************ *******@martinz .co.nz> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
> Hi,
>
> I have a standard aspx page (form) that contains a few user controls.
> Upon form submission the page is validated.
> If validation passses then a text based email is sent.
> This is all working fine, however what I would like to do is sent the
> entire contents of the posted back page as a HTML email.
>
> Is this possible and if so could somebody point me in the right direction > to achieving this.
>
> many thanks in advance.
>
> cheers
>
> martin.
>
>
>



Nov 19 '05 #4
Hi steve,

I look at the 4guys article, this seems to work fine if the control is a
datagrid.
If I make my own user control and put on instance of it on a page (called
SimpleControl1)
The user control only has a single text box on it

and use the following code

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter( sw)
SimpleControl1. RenderControl(h tmlWriter)

I get an error when I try to do a post back (the above code is in a button
on a PAGE not the user control) saying that

"Control 'SimpleControl1 _TextBox1' of type 'TextBox' must be placed inside a
form tag with runat=server"

I am not quite sure why this does not happen with the datagrid in 4guys
example.

If you could offer any advice it would be appreciated.

ideally I would like to send the output of the entire page (including all
user controls).
perhaps I will have to use a third party componenet.
cheers

martin.


"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:up******** *******@TK2MSFT NGP10.phx.gbl.. .
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Martin" <ma************ *******@martinz .co.nz> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hi,

I have a standard aspx page (form) that contains a few user controls.
Upon form submission the page is validated.
If validation passses then a text based email is sent.
This is all working fine, however what I would like to do is sent the
entire contents of the posted back page as a HTML email.

Is this possible and if so could somebody point me in the right direction
to achieving this.

many thanks in advance.

cheers

martin.


Nov 19 '05 #5
I've also encountered your problem, it's thought to be the case when
Page.Render() render the page twice and counted the page's form tag twice.
But since my form is actually a report, I just hide the user-input
parts(i.e.: the whole<form runat="server"> </form>) in a <asp:panel> and hide
it before the mail function's Page.Render() calls. Since everything inside a
Panel with .Visible set to false won't render, it won't case problem.

"Martin" <ma************ *******@martinz .co.nz> 秎ン
news:ug******** ******@TK2MSFTN GP12.phx.gbl い级糶...
Hi Lau,

I called page.render from a button click on the page.
I used the following code.

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter( sw)
Me.Render(htmlW riter)
I got an error saying "The page can only have one server-side form tag"
I guess the page thinks it is being rendered twice.

do you have any suggestions??

cheers

martin.



"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
Actually, emailing the content produced by Page.Render() will do the job
if
the page you want to email is the page itself. And it would be a lot
simpler.

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> 秎ン
news:up******** *******@TK2MSFT NGP10.phx.gbl い级糶...
You can email a page by using the WebRequest and MailMessage classes.

Here are a couple examples:
http://www.aspalliance.com/stevesmit...ailwebsite.asp
http://aspnet.4guysfromrolla.com/articles/091102-1.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Martin" <ma************ *******@martinz .co.nz> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
> Hi,
>
> I have a standard aspx page (form) that contains a few user controls.
> Upon form submission the page is validated.
> If validation passses then a text based email is sent.
> This is all working fine, however what I would like to do is sent the
> entire contents of the posted back page as a HTML email.
>
> Is this possible and if so could somebody point me in the right

direction
> to achieving this.
>
> many thanks in advance.
>
> cheers
>
> martin.
>
>
>



Nov 19 '05 #6
yes I see that your work around would work if you didn't need to get the
user input.
But in my case I actually want the user input so hiding the entire form in
an asp panel is not an option.

I am hoping to be able to retrive the HTML generated from the "re render"
event but I have been unsuccessful at present.

thanks for your help though.

cheers

martin.

"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:Or******** ********@TK2MSF TNGP12.phx.gbl. ..
I've also encountered your problem, it's thought to be the case when
Page.Render() render the page twice and counted the page's form tag twice.
But since my form is actually a report, I just hide the user-input
parts(i.e.: the whole<form runat="server"> </form>) in a <asp:panel> and
hide
it before the mail function's Page.Render() calls. Since everything inside
a
Panel with .Visible set to false won't render, it won't case problem.

"Martin" <ma************ *******@martinz .co.nz> 秎ン
news:ug******** ******@TK2MSFTN GP12.phx.gbl い级糶...
Hi Lau,

I called page.render from a button click on the page.
I used the following code.

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter( sw)
Me.Render(htmlW riter)
I got an error saying "The page can only have one server-side form tag"
I guess the page thinks it is being rendered twice.

do you have any suggestions??

cheers

martin.



"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
> Actually, emailing the content produced by Page.Render() will do the
> job
> if
> the page you want to email is the page itself. And it would be a lot
> simpler.
>
> "Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> 秎ン
> news:up******** *******@TK2MSFT NGP10.phx.gbl い级糶...
>> You can email a page by using the WebRequest and MailMessage classes.
>>
>> Here are a couple examples:
>> http://www.aspalliance.com/stevesmit...ailwebsite.asp
>> http://aspnet.4guysfromrolla.com/articles/091102-1.aspx
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>>
>>
>> "Martin" <ma************ *******@martinz .co.nz> wrote in message
>> news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
>> > Hi,
>> >
>> > I have a standard aspx page (form) that contains a few user
>> > controls.
>> > Upon form submission the page is validated.
>> > If validation passses then a text based email is sent.
>> > This is all working fine, however what I would like to do is sent
>> > the
>> > entire contents of the posted back page as a HTML email.
>> >
>> > Is this possible and if so could somebody point me in the right
> direction
>> > to achieving this.
>> >
>> > many thanks in advance.
>> >
>> > cheers
>> >
>> > martin.
>> >
>> >
>> >
>>
>>
>
>



Nov 19 '05 #7
Here's an article on how to disable form validation:
http://msdn.microsoft.com/msdnmag/is...d/default.aspx

I've not tried it, but you may take a look.

I suspect that deleting all runat=server from the page may also work,
because it's known that the input tags will preserve it's content even if
you don't do anything on it to preserve it. Just that don't know it's by the
client-side or server-side. If it's done by server-side, it'll work and you
can still access the form values through Response.Form[].

"Martin" <ma************ *******@martinz .co.nz> 秎ン
news:%2******** **********@TK2M SFTNGP10.phx.gb l い级糶...
yes I see that your work around would work if you didn't need to get the
user input.
But in my case I actually want the user input so hiding the entire form in
an asp panel is not an option.

I am hoping to be able to retrive the HTML generated from the "re render"
event but I have been unsuccessful at present.

thanks for your help though.

cheers

martin.

"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:Or******** ********@TK2MSF TNGP12.phx.gbl. ..
I've also encountered your problem, it's thought to be the case when
Page.Render() render the page twice and counted the page's form tag twice. But since my form is actually a report, I just hide the user-input
parts(i.e.: the whole<form runat="server"> </form>) in a <asp:panel> and
hide
it before the mail function's Page.Render() calls. Since everything inside a
Panel with .Visible set to false won't render, it won't case problem.

"Martin" <ma************ *******@martinz .co.nz> 秎ン
news:ug******** ******@TK2MSFTN GP12.phx.gbl い级糶...
Hi Lau,

I called page.render from a button click on the page.
I used the following code.

Dim sb As New StringBuilder
Dim sw As New StringWriter
Dim htmlWriter As New HtmlTextWriter( sw)
Me.Render(htmlW riter)
I got an error saying "The page can only have one server-side form tag"
I guess the page thinks it is being rendered twice.

do you have any suggestions??

cheers

martin.



"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
> Actually, emailing the content produced by Page.Render() will do the
> job
> if
> the page you want to email is the page itself. And it would be a lot
> simpler.
>
> "Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> 秎ン
> news:up******** *******@TK2MSFT NGP10.phx.gbl い级糶...
>> You can email a page by using the WebRequest and MailMessage classes. >>
>> Here are a couple examples:
>> http://www.aspalliance.com/stevesmit...ailwebsite.asp >> http://aspnet.4guysfromrolla.com/articles/091102-1.aspx
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>>
>>
>> "Martin" <ma************ *******@martinz .co.nz> wrote in message
>> news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
>> > Hi,
>> >
>> > I have a standard aspx page (form) that contains a few user
>> > controls.
>> > Upon form submission the page is validated.
>> > If validation passses then a text based email is sent.
>> > This is all working fine, however what I would like to do is sent
>> > the
>> > entire contents of the posted back page as a HTML email.
>> >
>> > Is this possible and if so could somebody point me in the right
> direction
>> > to achieving this.
>> >
>> > many thanks in advance.
>> >
>> > cheers
>> >
>> > martin.
>> >
>> >
>> >
>>
>>
>
>



Nov 19 '05 #8

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

Similar topics

3
3346
by: Erik T. Nomad | last post by:
I've created a link that will enable the reader of any page on my website to click it, enter an e-mail address, and have it arrive in that inbox with a hyperlink to the site. However, I'm wondering if there's a way to customize it further, such that the hyperlink they are sent is the web address of the page the "send to friend" link was on. I don't want to convert my entire site over to .asp, so having a pop-up .asp page seems to make...
4
2459
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 Windows 2000 Server, but now under Server 2003 it seems that characters above 127 get converted somehow, and our code no longer produces the desired effect.
11
5025
by: Tim Smallwood | last post by:
Hi, I have an Access project that I use to allow a client to hit an SQL server at my host. This project has several forms that are used to udpate tables, etc, but I'd also like to be able to include the ability to allow my client to send an email to everyone that has subscribed to our web site by going to the table that contains the names and email addy's and then loop thru the same and send an email to them all by appending their...
9
3146
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 other page, or is there something else like a stream which will be like a file. I am attempting to get a way from writing out a file and then having to give the page that I am posting to the file name. Instead I would like to just from asp.net...
1
1433
by: winstontuck | last post by:
Hi I am busy with a webapplication and would like to know what is the best way to send an email from within the application. Thank you.
9
77428
by: Mahernoz | last post by:
Can i send an email from JavaScript? Is it possible? If yes please the code to send email using javascript...
7
1602
by: canajien | last post by:
How can I get a php page to automatically send all the contents in an email when it is generated? I managed to hack together a script that sends an email, but it will only send the 1st record returned and I would like it to send all the records that are on the page when it is loaded. <?php $con = mysql_connect("localhost","user","pass"); if (!$con)
4
2544
by: fjm | last post by:
Hello eveyone Is there a way to email an entire html page after the page is processed for data? What I have is an entire html page that draws data from a db. I would like to email that form before the foreach loop goes back to create another form. <html> <body> foreach()......
2
1957
by: Ty | last post by:
I have a Web site project in VS 2008 vb.net. What I'm trying to do is send a page by email via a button click. I have tried to use this as an example. http://www.systemnetmail.com/faq/4.8.aspx While this did allow me to send a page by email the problem is that this site is an authenticated site so the page sent was the log in page. So that leads me to this question. Is there a way to invoke copy and
0
8590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we抣l explore What is ONU, What Is Router, ONU & Router抯 main usage, and What is the difference between ONU and Router. Let抯 take a closer look ! Part I. Meaning of...
0
8947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8781
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8784
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6453
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4543
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2214
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.