0
Conundrum

Attn: Web Developers - I need help with Forms and .ASP

Recommended Posts

Say you've got a form like so:


Subject:

From:

Body:



Then create an ASP file called 'email.asp' (or whatever your action is called in your form) like so:

<%
Set mail = Server.CreateObject("CDO.Message")
mail.To = 'email address destination'
mail.From = Request.Form("From")
mail.Subject = Request.Form("Subject")
mail.TextBody = Request.Form("Body")
mail.Send()
Response.Write("Mail Sent!")
Set mail = nothing
%>

This will give you a basic text email. Try looking up some tutorials for ASP Mail. That will also give you some help.

Share this post


Link to post
Share on other sites
Its easy. Fields have to match between the form and the ASP or they will not be transmitted. The ASP file needs to be named something like xyz.asp, in the Action= area you need to put in Action=xyz.asp".
Yesterday is history
And tomorrow is a mystery

Parachutemanuals.com

Share this post


Link to post
Share on other sites
Quote

I'm lost. :S



I'll see if I can explain it a bit more.

Ok so say your basic "form" page asks a few questions.. (lets call this page form.htm for arguments sake)
example

SUBJECT
FROM
BODY

hence the code below...

"form.htm"



Subject:

From:

Body:




So that will make a basic page with input fields for the visitor to fill in those 3 things. You can change those fields to what ever you want.

Now pay attention to this line


this tells the "form.htm" page what to do once the user presses the 'submit' button. It will look for the "email.asp" page.


Now lets talk a bit more about the "email.asp" page



Set mail = Server.CreateObject("CDO.Message")
mail.To = 'email address destination'
mail.From = Request.Form("From")
mail.Subject = Request.Form("Subject")
mail.TextBody = Request.Form("Body")
mail.Send()
Response.Write("Mail Sent!")
Set mail = nothing
%>


There is a couple lines here to pay attention too.
mail.To = 'email address destination' 

Insert your email address there.


Make sure these 3 lines match what you have on your "form.htm" page.. remember the 3 input fields that were created

SUBJECT
FROM
BODY

make sure they match what is in the (" ") below.
example if you named something "Subject" above make sure it matches up as ("Subject") below..


mail.From = Request.Form("From")
mail.Subject = Request.Form("Subject")
mail.TextBody = Request.Form("Body")



hope this helps..

Thanks to tilley13k for the above code, saved me having to type it all again.

Share this post


Link to post
Share on other sites
Heres the code commented and broken down to explain it better...






Subject:



From:



Body:










Now we will look at email.asp and what its doing.



<% 'This is starting a block of asp code

Set mail = Server.CreateObject("CDO.Message")
'Creating an object that enables you to send a msg calling it "mail"

mail.To = '[email protected]'
' Telling the variable who to send the message too

mail.From = Request.Form("From")
'Retrieving the information from the previous forms "from" field and storing it

mail.Subject = Request.Form("Subject")
'Retrieving the information from the previous forms "subject" field and storing it

mail.TextBody = Request.Form("Body")
'Retrieving the information from the previous forms "body" field and storing it

mail.Send()
'Sending all the information collected above to the email address

Response.Write("Mail Sent!")
'This will tell the user that the mail has been sent,
you can add some html code here if you look up how
Set mail = nothing
'Resetting the variable to null

%> ' This is closing off the block of asp code


This is in laymans terms and not exactly what the code is doing, but its explained like that to make it easy to understand.

Share this post


Link to post
Share on other sites
Call this page "email.asp" and upload it to the same directory as where ever your "form" page is.



<%
Set mail = Server.CreateObject("CDO.Message")
mail.To = "[email protected]"
mail.From = Request.Form("From")
mail.Subject = Request.Form("Subject")
mail.TextBody = Request.Form("Body")
mail.MailFormat = 0
mail.BodyFormat = 0
mail.Send()
Response.Write("Mail Sent!")
Set mail = nothing
%>


THIS IS ASSUMING, that what ever your form page is has some input's named From, Subject and Body

Example you should see something similar to these 3 lines (what matters is the part thats in bold)

name="Subject"/>
name="From"/>


If you still don't understand, post the code to your forms page, or pm me it.

edit to add: the form page must also contain this line

Share this post


Link to post
Share on other sites
If you have any control over the architecture of the general site, I strongly suggest checking out DotNetNuke, www.DotNetNuke.com, which provides a content management system with a whole slew of modules already available that are likely to solve your problem without writing any code.

Specifically, you can set up a page using the User Tables module that will allow them to enter information and will send you the results.
Matt Christenson

[email protected]
http://www.RealDropzone.com - A new breed of dropzone manifest software.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

0