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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I mail form input?

Status
Not open for further replies.

Shrp

IS-IT--Management
Jan 9, 2002
82
US
I have an ASP that displays the entries the user put
into a form:

T1 = Request.Form("p1")
T2 = Request.Form("p2")

Response.Write "You entered " & T1 & " and " T2 " &
" - is that correct?"

...and if they click "Submit" then I would like it (or
another ASP) to e-mail the T1 and T2 to a particular
address - how can I do this?

Thanks!
 
this is for ASPmail
<body>
<%
T1 = Request.Form(&quot;p1&quot;)
T2 = Request.Form(&quot;p2&quot;)

Response.Write &quot;You entered &quot; & T1 & &quot; and &quot; T2 &quot; &
&quot; - is that correct?&quot;
%>
<form name=&quot;frm&quot; method=&quot;form&quot; action=&quot;mailIt.asp&quot;>
<input type=&quot;hidden&quot; value=&quot;<%= T1 %>&quot; name=&quot;T1&quot;>
<input type=&quot;hidden&quot; value=&quot;<%= T2 %>&quot; name=&quot;T2&quot;>
<input type=&quot;submit&quot; value=&quot;Yes, Submit form&quot;>
</form>
</body>
</html>

mailIt.asp
<%
Dim T1, T2
T1 = Request.Form(&quot;T1&quot;)
T2 = Request.Form(&quot;T2&quot;)

'everything with the &quot;value&quot; needs to be filled out

DIM Mailer, strMsgHeader
Set Mailer = Server.CreateObject(&quot;SMTPsvg.Mailer&quot;)
Mailer.FromAddress= &quot;value&quot;
Mailer.RemoteHost = &quot;value&quot;
Mailer.AddRecipient &quot;value&quot;
Mailer.Subject = &quot;value&quot;
strMsgHeader = &quot;value&quot; & vbCrLf & vbCrLf
Mailer.BodyText = strMsgHeader & vbCrLf & &quot;T1: &quot; & T1 & _
vbCrLf & &quot;T2: &quot; & T2
IF Mailer.SendMail THEN
Response.Write &quot;Your message has been successfully sent.&quot;
ELSE
Response.Write &quot;The following error occurred while sending your message: &quot; & Mailer.Response
END IF
%>

using CDONTS is very similar
here is how you might do it that way
mailIt.asp
<%
<%
Dim T1, T2
T1 = Request.Form(&quot;T1&quot;)
T2 = Request.Form(&quot;T2&quot;)

'everything with the &quot;value&quot; needs to be filled out

set mail=server.CreateObject(&quot;CDONTS.NewMail&quot;)
mail.From= &quot;value&quot; 'blah.com
mail.To = &quot;value&quot; 'blah@blah.com
mail.Subject = &quot;value&quot; ' form name
mail.Body = &quot;T1: &quot; & T1 & vbCrLf & &quot;T2: &quot; & T2
mail.Send
set mail=nothing
%>

this little bit will send a email but I would get into it more, try here
admin@onpntwebdesigns.com
 
that's
method=&quot;post&quot;
sorry typing way too fast, the example shows taht you need to resubmit the values also. hence the hidden form fields

I had a extra <% in there too. wow, maybe I should get some sleep [lol]
admin@onpntwebdesigns.com
 
ASPmail and CDONTS - would these normally be supported
by any web hoster that supports my ASPs? Or, should I
ask my web host tech support?

Thanks for the help!!
 
ASPmail is a component that is usually available but may not be. CDONTS as far as I know can be used anytime. If you hafe ASP support it is likely they have ASPmail support. you should jsut be able to check on the stat's of the hosting companies site.
admin@onpntwebdesigns.com
 
Now I have it like this:

T1 = Request.Form(&quot;p1&quot;)
T2 = Request.Form(&quot;p2&quot;)

Response.Write &quot;You entered &quot; & T1 & &quot; and &quot; T2 &quot; &
&quot; - is that correct?&quot;

...and if they click &quot;Submit&quot; then it runs the following,
but that results in &quot;HTTP 500 - Internal server error&quot;

<%
set mail = server.CreateObject(&quot;CDONTS.NewMail&quot;)
mail.From = &quot;Some Guy<someguy@guy.com>&quot;
mail.To = &quot;Shrp<me@myaddress.net>&quot;
mail.Subject = &quot;subject&quot;
BodyText = &quot;This is a sample email.&quot; & vbCRLF
BodyText = BodyText & &quot;It was sent using CDONTS on WinXP&quot; & vbCRLF
mail.Body = BodyText
mail.Send
%>

I don't even use any of the form variables, and have very
little to go on... help? :)
 
try this, if it gives you a error like this
Server.CreateObject Failed

then you need to find out what type of mail components are set up with your service.
<%
Dim mail, BodyText
set mail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
mail.From = &quot;email@somewhere.com&quot;
mail.Subject = &quot;this is a test for you!&quot;
mail.To = &quot;youremail@you.com&quot;
BodyText = &quot;This is a sample email to test for CDONTS.&quot; & vbcrlf &_
&quot;It was sent using CDONTS on WinXP&quot; & vbcrlf
mail.Body = BodyText
mail.Send
Response.write(&quot;Mail was Sent so you have the SMTP for CDONTS installed on the server&quot;)
Set objMail = nothing

%>

admin@onpntwebdesigns.com
 
forgot to tell you the response.write may be in the URL after you try to open this page. so what I mean is if you type and hit go you will see the url change to

not sure but I know this is how it would work if you ran jsut that code with ASPmail...jsut incase!
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top