There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
ASP help


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
charliekim's Avatar
Senior Member with 140 posts.
 
Join Date: Jun 2002
23-Dec-2003, 02:21 AM #1
ASP help
hello all.

does anyone know how to create a small asp program that will send to a specific email after a user has inputed their info in some forms..

for example... this is the form...

<Form action="something.asp" method="post">
<p>Enter your name :
<input type="text" name="name" size="20"/></p>
<p>Enter your email :
<input type="text" name="email" size="20"/></p>
<p>Prayer Request :</p>
<textarea name="comments" rows="4" cols="36"></textarea><br><br>
<input type="submit" value="Submit"/>
<input type="reset" value="Clear"/>

when the user presses submit, the info will be passed to the webserver where something.asp is, and that asp program will return all the info to a particular email address..

another example would be, when someone enters John Smith , john@smith.com, and please pray for my health....... John Smith presses enter...

all the info will be sent to the server, and the asp will process that info, and send me back everything John Smith filled in, but to my email account..

hope this is not too confusing..

thanks..
ck
DJ-TM's Avatar
Registered User with 38 posts.
 
Join Date: Jul 2003
23-Dec-2003, 03:51 AM #2
your asp page would look like this:

<%

'This is collecting the information from the form

name = request.form("name")
email = request.form("email")
comments = request.form("comments")

'This is setting the body of the email

mailbody = ("Name: ") & (name) & (" Email: ") & (email)
mailbody = mailbody & (" Comments: ") & (comments)

'This is using CDONTS

Set objSendMail = Server.CreateObject("CDONTS.NewMail")
objSendMail.To ="enter your email address here"
objsendmail.from ="put anything you like here"
objSendmail.subject= "anything you like"
objSendMail.Body = mailbody
objsendmail.send
set objCDOMail = nothing

%>

That will send you an email with all the details that were entered by a user, you may want to format the email using html just so it looks nicer.
charliekim's Avatar
Senior Member with 140 posts.
 
Join Date: Jun 2002
23-Dec-2003, 10:43 AM #3
would i keep the form elements as it is though?
DJ-TM's Avatar
Registered User with 38 posts.
 
Join Date: Jul 2003
23-Dec-2003, 10:45 AM #4
yep keep all you input boxs/text area the same as you have them now.

just make sure to put the name of the asp page in the action propety of the html form.
charliekim's Avatar
Senior Member with 140 posts.
 
Join Date: Jun 2002
23-Dec-2003, 10:49 AM #5
oh , so that asp code will be in a separate asp page..

i can create that in text pad, and save it as mail.asp for example.
?
charliekim's Avatar
Senior Member with 140 posts.
 
Join Date: Jun 2002
23-Dec-2003, 05:44 PM #6
this is the asp code that you gave me, but have modified for my specifications.

<% @language = vbscript %>

<% Option Explicit %>

<%

'This is collecting the information from the form

name = request.form("name")
email = request.form("email")
comments = request.form("comments")

'This is setting the body of the email

mailbody = ("Name: ") & (name) & (" Email: ") & (email)
mailbody = mailbody & (" Comments: ") & (comments)

'This is using CDONTS

Set objSendMail = Server.CreateObject("CDONTS.NewMail")
objSendMail.To ="ck@akyg.com"
objsendmail.from =name
objSendmail.subject= "Prayer Request"
objSendMail.Body = mailbody
objsendmail.send
set objCDOMail = nothing

%>


all seems ok?

and for the objsendmail.from = name

i took out the double quotes so the variable can be passed, rather than "name" appearing as a string literal.

please check it out for me
thanks you
DJ-TM's Avatar
Registered User with 38 posts.
 
Join Date: Jul 2003
24-Dec-2003, 05:16 AM #7
just a couple of points :

if your using option explicit you will need to declare all you variables e.g.

Dim name, email, comments, mailbody

also would it not be better to have

objsendmail.from = email

rather than

objsendmail.from = name

so there email address appears in the from field,.

also the objsendmail.from property must not contain any spaces or it will not work.
Mithrilhall's Avatar
Senior Member with 781 posts.
 
Join Date: Mar 2001
Location: AU Microscopii
Experience: Studying for my CCNA
25-Dec-2003, 02:32 AM #8
objsendmail.from = Replace(email, " ", "")

That should help with spaces.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:04 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.