How Do I send the current form as e-mail

K

Kassam

Hi MVPs out there.

I have constructed an order form and the users will enter the informtion. I
now need to send the filled out form as an e-mail (body being the HTML with
the fille din data) to a predefined e-mail address. I know how to use CDO. I
don't want to go to another page to recontruct the HTML as the '.body'
Thank you in anticipation.

Kassam
 
J

Jeff Cochran

Hi MVPs out there.

I have constructed an order form and the users will enter the informtion. I
now need to send the filled out form as an e-mail (body being the HTML with
the fille din data) to a predefined e-mail address. I know how to use CDO. I
don't want to go to another page to recontruct the HTML as the '.body'
Thank you in anticipation.

So don't go to another page, post back to the same page. Construct
the body as you wish, and use variables for the form field values.
Post back to the same form, and fill the values back into the form
from the posted values at the same time as you fill in the body of the
email. Use an If/Then to determine if the page has been posted back,
using a hidden field, and if so, do the CDO bits.

Jeff
 
R

Roland Hall

in message
: On Thu, 2 Jun 2005 12:53:18 -0700, Kassam
:
: >Hi MVPs out there.
: >
: >I have constructed an order form and the users will enter the informtion.
I
: >now need to send the filled out form as an e-mail (body being the HTML
with
: >the fille din data) to a predefined e-mail address. I know how to use
CDO. I
: >don't want to go to another page to recontruct the HTML as the '.body'
: >Thank you in anticipation.
:
: So don't go to another page, post back to the same page. Construct
: the body as you wish, and use variables for the form field values.
: Post back to the same form, and fill the values back into the form
: from the posted values at the same time as you fill in the body of the
: email. Use an If/Then to determine if the page has been posted back,
: using a hidden field, and if so, do the CDO bits.

To add to what Jeff wrote...

I wrap my HTML in server-side VBScript as one string. Then when I post back
to the same page, the string will be filled in with my input variables and
that is the HTML content I send out with CDOSYS.

I only send the output via mail if the form has been posted. An easy way to
check is to add a name value pair to your submit button.

sub prt(str)
Response.Write str & vbCrLf
end sub

prt "<html>"
prt "<body>"
prt "<form action="""" method=""post"" />"
prt "<input type=""text"" name=""iname"" value="""" /><br />"
' additional form input elements
prt "<input type="submit" name="submit value="Submit" />"
prt "</form>"
prt "</body>"
prt "</html>"

Then put everything in this conditional to see if you post to the screen or
send via mail.

dim s, strName, valid
strName = Server.HTMLEncode(Replace(Request.Form("iname"),"'","''"))
s = Server.HTMLEncode(Replace(Request.Form("submit"),"'","''"))
if s <> "" then
' validate input
if valid then
' mail it
prt "Thank you"
prt "<span style=""cursor: pointer; border: 1px solid black;
background-color: #efe"" onclick=""location.href='/'"">Continue</span>"
Response.End
else
' Post error
' Fall through to display form on screen
end if
end if

None of this is tested for errors/typos.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top