|
-
Jun 18th, 2002, 12:37 AM
#1
Thread Starter
Addicted Member
Need a Server page to e-mail me
Im strictly a client side developer but now Im doing something personal. So I need to do a server side function. Basically, all I need to do is take the info from the submited form and mail it to my e-mail address. I dont need any validation cause Im gonna do all that client side and none of this info is going into a database. I just need to know how to make an ASP that will do this. I want to do this server side to avaid the client side hassles with mailto: and the dialog box and all. So all I need is some ASP code that will say:
Hey, take this form info and mail it to javans e-mail adress and make sure its in text/plain format.
Thats all I need. I dont mind any cut and paste code, so please give me something. I wouldnt normally ask someone to "do my job" but I figured this is easy enough where its just a quick snippet of code (although I could be wrong). Please, give me the FULL code that I need to use as I will be using that as my form action url. Thanks in advance.
-
Jun 18th, 2002, 03:49 AM
#2
Fanatic Member
If you have ISS4-5 then you have access to the Collaboration Data Objects for NT Server, also known as CDONTS.
The example below shows a simple way of using it.
Code:
<%
Dim MyBody
Dim MyCDONTSMail
Set MyCDONTSMail = Server.CreateObject("CDONTS.NewMail")
With MyCDONTSMail
.From= "[email protected]"
.To= "[email protected]"
.Subject="This is a Test"
.Body= "A Bunch Of Text"
.Send
End With
set MyCDONTSMail=Nothing
%>
-
Jun 18th, 2002, 09:21 AM
#3
Thread Starter
Addicted Member
YEah, but.... I need to capture the data from my form. I dont see in that code it catching the data on the form. I just need it to grab that data and e-mail it to my e-mail adress
-
Jun 18th, 2002, 09:40 AM
#4
PowerPoster
Use the request.form collection
Code:
UserEmail = request.form("Emailfieldname")
-
Jun 18th, 2002, 10:11 AM
#5
Fanatic Member
Oh sorry, yeah, I forgot about that.
VeryJonny is right. varname = request.form("elementname") if your using POST as the method or varname = request.querystring("elementname") if you are using GET.
-
Jun 18th, 2002, 10:12 AM
#6
Thread Starter
Addicted Member
So you're telling me that I only have to use that one line of code?! I dont need anything else?
UserEmail = request.form("Emailfieldname")
what do I save it as?.asp?
Also, The e-mailfield name is my e-mail address?
-
Jun 18th, 2002, 10:18 AM
#7
Thread Starter
Addicted Member
Guys, I really apreciate your help. But Im really a dummy when it comes to server side programming. Please, show me the complete code and explain it to me as you would a child
-
Jun 19th, 2002, 07:06 AM
#8
PowerPoster
hi
first.htm
Accept email of user who sends you the email.
submit this form to say page Process.asp
Process.asp contains all the code above.
in Process.asp you use request.querystring if u have used get method in the first.htm - form else you use request.form to get the email address of the user.
Your email email can be hard coded in the .To part of the code.
-
Jun 19th, 2002, 09:08 AM
#9
Thread Starter
Addicted Member
Thanks, but the client is not going to e-mail me. They are gonna fill out a form on my website, then I want that info from that from to go to the server where it grabs that info and e-mails it to my address. I know I can just have it e-mail me from the client but then you have the dialog box come alerting the client. I dont want that.
veryjonny, Im sorry but your last post confused me even more. Could you just put the code all together for me and just show me how to post it up and where I need to put my e-mail address in it?
Thanks
-
Jun 19th, 2002, 09:37 AM
#10
PowerPoster
sorry for confusing you.
First a clarification now. You are making this VB or asp/html pages?
-
Jun 19th, 2002, 09:43 AM
#11
Thread Starter
Addicted Member
this is for an HTML form submiting the form info back to the server. I am completely a client side developer, so I know nothing of server side processing. No even something as simple as taking the form data and e-mailing it to my web address. So yes, it is for html/asp. I just need a simple asp page that takes the form data and e-mails it to my e-mail adress. I dont need any validation because Im doing all that on the client. Thanks
-
Jun 19th, 2002, 09:54 AM
#12
PowerPoster
hi
Do you know the action part (attribute) set it to the asp page where the processin gwould take place (say Process.asp) and set the method = post.
Now in the form you have textboxes, comboboxes and other things. to collect this data we use request.form collection like this:
Code:
mname = request.form("FieldnameMname")
'you collect all the data similarly
'now say this data needs to be emailed to you then use:
Dim MyBody
Dim MyCDONTSMail
Set MyCDONTSMail = Server.CreateObject("CDONTS.NewMail")
With MyCDONTSMail
.From= "Webform@unknown" 'since you do not know who submitted it
.To= "[email protected]"
.Subject="Web form submitted"
.Body= mname & allthe other variables
.Send
End With
set MyCDONTSMail=Nothing
Hope this helps
-
Jun 19th, 2002, 12:07 PM
#13
Thread Starter
Addicted Member
thank you very much. for the:
mname = request.form("FieldnameMname")
do I have to write this over for each field on my form
for instance, lets sayI have two text inputs:
<input type="text" name="firstname" />
<input type="text" name="lastname" />
do I put
fame = request.form("firstname")
lame = request.form("lastname")
or could I just send myself the whole form if I had:
<form name="infoform">
could I just put:
mname = request.form("infoform")
also, why do I have to dim MyBody. I dont see it used anywhere in the code. Thanks again
-
Jun 20th, 2002, 03:31 AM
#14
PowerPoster
hi
Sorry about the dim there is no need to dim mybody unless you want add (concatenate all the form data into one variable and assign it to body of the messge in the line .body = MybOdy
Also yes you will need to request.form for ALL the fieldnames in the form.An alternative would be:
Code:
mybody = ""
for each i in request.form
mybody = mybody & vbcrlf & i & " = " & request.form(i) & "<br>"
next
'now mybody contains all the name = value pair of your form
-
Jun 20th, 2002, 09:08 AM
#15
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|