473,396 Members | 1,797 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,396 software developers and data experts.

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 2132
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****************@TK2MSFTNGP15.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.net> ¦b¶l¥ó
news:up***************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
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****************@TK2MSFTNGP15.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(htmlWriter)
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.com.hk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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.net> ¦b¶l¥ó
news:up***************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
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****************@TK2MSFTNGP15.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(htmlWriter)

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.net> wrote in message
news:up***************@TK2MSFTNGP10.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****************@TK2MSFTNGP15.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> ¦b¶l¥ó
news:ug**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
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(htmlWriter)
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.com.hk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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.net> ¦b¶l¥ó
news:up***************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
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****************@TK2MSFTNGP15.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.com.hk> wrote in message
news:Or****************@TK2MSFTNGP12.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> ¦b¶l¥ó
news:ug**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
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(htmlWriter)
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.com.hk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
> 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.net> ¦b¶l¥ó
> news:up***************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
>> 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****************@TK2MSFTNGP15.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> ¦b¶l¥ó
news:%2******************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
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.com.hk> wrote in message
news:Or****************@TK2MSFTNGP12.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> ¦b¶l¥ó
news:ug**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
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(htmlWriter)
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.com.hk> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
> 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.net> ¦b¶l¥ó
> news:up***************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
>> 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****************@TK2MSFTNGP15.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
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...
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...
11
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...
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...
1
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
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
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...
4
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...
2
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 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
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...
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,...

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.