Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending emails from a webpage

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
US
hi,
i know this subject has come up a 100 times here and i may haved one of those examples in the past. however, any examples that i found, didn't work for my app. maybe somebody can help me find out why.

i have a web page on a host serve that has a form like this below. users can log on to the web, go the the current page and click submit.
<form name="frm1" action="newpage.asp" method="post">
i want to send an email before the current page goes to newpage.asp. is it possible?
thanks.
 
You could post the page to itself, send an email and redirect to wherever you want to go or you could use something like this:

<form name="frm1" action="intermediatepage.asp" method="post">

On intermediatepage.asp

'Capture posted variables
'=====================
name= Request.Form("name")
email= Request.Form("email")
phone= Request.Form("phone")
etc.etc
url= "newpage.asp"
'=============================
Create & send email using form variables

'===============================
add posted variables to db or not
do whatever you want before posting string

'========================================
'create form post string
'========================================

SendString="name=" & name &_
"&email=" & email &_
"&phone=" & phone &_
"&etc=" & etc &_
"&etc=" & etc &_
"&etc=" & etc

'=======================================
'send form string to newpage.asp
'======================================

Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
objWinHttp.open "POST", url, false
objWinHttp.setRequestHeader "Content-Type", "application/x-objWinHttp.send SendString
Response.write objWinHttp.responseText
set objWinHttp = nothing

This isn't very secure without stripping the form field data etc but it should work
 
thanks so much for the reply.
i'm not sure if i understand your solution. does this send an email? where's the subject? from? to? what i need is an email to be sent with from, to, subject, body and cc.
thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top