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

When form submits - Send an e-Mail: How? 1

Status
Not open for further replies.

DSect

Programmer
Sep 3, 2001
191
US
I took over a website that was super-duper FrontPage server extension dependant.

In converting most of the forms to normal, non-wizarded .ASP, I ran into a small problem.

With this one form, a user submits info, presses submit and 2 things happen: 1. The info is inserted into a CSV file (ala FrontPage extensions) 2. An e-mail is dispatched to the person who works with the data.

Now I got the form/information insertion to database stuff with no problem, but I need to do something so that one of our staff will be notified when information is entered.

So - I would really like to make a small .ASP thing that takes information from one of my form fields and sends an e-mail to a staff member with the field info in the subject line.

- OR -

I would like to be able to popup a little message on the workers' PC's when a record is inserted.

I friccin' hate FrontPage Extensions, but the FPx auto-mailer on form submit is useful, I just need to replicate it WITHOUT using FPx's.

I've heard of CDONTS, but I have alot to learn about using it. In fact, I don't really know too much about .ASP, but I'm coming along well..

I am not looking for an exact answer, but maybe just point me in the right direction as to what methods / techniques to use or your opinions on how to do this. If you say that you'd use CDONTS, then I'll look into that, but you don't need to be real specific at this point.. I'm just digging for ideas.

Again - I have an .ASP form going to an SQL database and I want to have one of my co-workers receive an e-mail or some kind of notification when the form is submitted or the record is inserted.

Please help me get away from this FrontPage extension crap!!!!

Thanks in advance, as always!

*D*
 
The quickest way I have found is ASPEmail just install a small programe on the server and add a few line sof code and your set.
 
Heres a sample of CDONTS should help you get on your way.
check out sites like devguru.com, asp.com, and learnasp.com they will help you alot.
<%
' change these to reflect where form should go
fromName=&quot;Whoever&quot;
fromAddress=&quot;somestudent@activeserverpages.com&quot;
toName=&quot;Charles M. Carroll&quot;
toAddress=&quot;cc@thebestweb.com&quot;
subject=&quot;form send mail tutorial&quot;
relay=&quot;mail.innerhost.com&quot;
%>
<html><head>
<title>FormToBeMailed.asp</title>
</head><body bgcolor=&quot;#FFFFFF&quot;>
<form action=&quot;FormToBeMailedrespond.asp&quot; method=&quot;GET&quot;>
Fill Out This Form For Us:<p>
First Name -&gt; <input NAME=&quot;NameFirst&quot; size=&quot;20&quot;><br>
Last Name -&gt; <input NAME=&quot;NameLast&quot; size=&quot;20&quot;><br>
Country -&gt; <input NAME=&quot;Country&quot; value=&quot;USA&quot; size=&quot;20&quot;><br>
State -&gt; <input NAME=&quot;State&quot; MaxLength=&quot;2&quot; size=&quot;2&quot;><br>
email copy to -&gt; <input NAME=&quot;emailcopy&quot; MaxLength=&quot;40&quot; size=&quot;40&quot;><br>

<input type=&quot;submit&quot;><input type=&quot;reset&quot;>

<% ' do not touch these lines. Needed to send mail! %>
<input type=&quot;hidden&quot; name=&quot;mail-from&quot; value=&quot;<%=fromName%>&quot;>
<input type=&quot;hidden&quot; name=&quot;mail-fromAddress&quot; value=&quot;<%=fromAddress%>&quot;>
<input type=&quot;hidden&quot; name=&quot;mail-to&quot; value=&quot;<%=ToName%>&quot;>
<input type=&quot;hidden&quot; name=&quot;mail-toaddress&quot; value=&quot;<%=toaddress%>&quot;>
<input type=&quot;hidden&quot; name=&quot;mail-subject&quot; value=&quot;<%=subject%>&quot;>
<input type=&quot;hidden&quot; name=&quot;mail-relay&quot; value=&quot;<%=relay%>&quot;>
</form>
</body></html>


Here is the generic form responder that can be used with this or any form:

<html><head>
<title>serverobjectsmailrespond.asp</title>
</head><body bgcolor=&quot;#FFFFFF&quot;>
<%
' ASPMail(tm) from ' is not part of ASP per se,
' but a excellent third party component

my_from=request(&quot;mail-fromName&quot;)
my_fromAddress=request(&quot;mail-fromaddress&quot;)
my_to=request(&quot;mail-toName&quot;)
my_toAddress=request(&quot;mail-toaddress&quot;)
my_subject=request(&quot;mail-subject&quot;)
my_relay=request(&quot;mail-relay&quot;)

Set Mailer = Server.CreateObject(&quot;SMTPsvg.Mailer&quot;)
Mailer.RemoteHost = my_relay

Mailer.FromName = my_from
Mailer.FromAddress = my_fromAddress
Mailer.AddRecipient my_to, my_toaddress
Mailer.Subject = my_subject

for each whatever in request.querystring
If instr(whatever,&quot;mail-&quot;)=0 then
Mailer.BodyText = whatever & &quot;=&quot; & vbcrlf
Mailer.BodyText = request.querystring(whatever) & vbcrlf & vbcrlf
end if
next

for each whatever in request.form
If instr(whatever,&quot;mail-&quot;)=0 then
Mailer.BodyText = whatever & &quot;=&quot; & vbcrlf
Mailer.BodyText = request.form(whatever) & vbcrlf & vbcrlf
end if
next

my_emailcopy=request(&quot;emailcopy&quot;)
If my_emailcopy=&quot;&quot; then
else
Mailer.AddRecipient &quot;form filler&quot;,my_emailcopy
end if

If Mailer.SendMail then
Msg = &quot;mail sent sucessfully!&quot;
Else
Msg = &quot;mail was not sent sucessfully<br>&quot;
msg = msg & mailer.response & &quot;<br>&quot;
End If
response.write Msg
%>
</body></html>
 
Wow guys - Thanks, spec' BlastRadius.

Like I said, I am very green, but when pointed in the right direction I can probably get it. Thanks for pointing me in the right direction and giving me some excellent examples!!

Super appreciate it - Hopefully I'll be able to repay you or others later on.

Thanks again!
-D-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top