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

auto email sender

Status
Not open for further replies.

ender165

Instructor
Feb 2, 2002
9
US
Pls point me in the right direction..

I'd like to have a specific pre-made email file go out to a site visitor... based on what link they clicke on. (or even what radio button they selected).

I don't need to set up an on-going email list... I just want the person to click something...get prompted for their email... and get the info they wanted within a few seconds.

not the same thing as an on vacation autoresponder.

ANy help would be greatly appreciated.Bascially this is fax back on demand... only via email

Thanks
Val
 
ender165,

you'll need to use server-side scripting of some sort, like CGI or ASP.

Here's a pretty basic example in ASP:

Code:
<%
Option Explicit
Dim sSubject, sBody, oEmail, bSent

If Request.QueryString(&quot;email&quot;) <> &quot;&quot; Then
	'get the correct subject & body text
	Select Case Request.QueryString(&quot;subject&quot;)
		Case &quot;lions&quot;
			sSubject = &quot;Lions:  really big cats&quot;
			sBody = &quot;This is what I know about lions.&quot;

		Case &quot;tigers&quot;
			sSubject = &quot;On the subject of tigers:&quot;
			sBody = &quot;I can tell you this about tigers.&quot;

		Case &quot;bears&quot;
			sSubject = &quot;So you want to learn about bears?&quot;
			sBody = &quot;What is a bear anyway?&quot;

	End Select

	'create email object, set its properties
	Set oEmail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
	oEmail.To = Request.QueryString(&quot;email&quot;)
	oEmail.From = &quot;me@mysite.com&quot;
	oEmail.Subject = sSubject
	oEmail.Body = sBody
	oEmail.Send
	
	'clean up
	Set oEmail = Nothing
	
	'show the confirm page
	bSent = true
End If
%>

<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 FINAL//EN&quot;>
<html>
<head>
<title></title>

<script name=&quot;javascript&quot;>
function sendEmail(sSubject) {
	sEmail = prompt(&quot;Please enter your email address for info on &quot; + sSubject + &quot;:&quot;,&quot;&quot;);
	if (sEmail && sEmail.length > 0)
		location.href = location.href + &quot;?subject=&quot; + sSubject + &quot;&email=&quot; + sEmail;
}
</script>

<style type=&quot;text/css&quot;>
</style>

<meta name=&quot;author&quot; content=&quot;?&quot;>
<meta name=&quot;keywords&quot; content=&quot;?&quot;>
<meta name=&quot;description&quot; content=&quot;?&quot;>
</head>
<body onload=&quot;&quot;>

<% If bSent = false Then %>

Click to get info on subject 1 &quot;lions&quot;:
<input type=&quot;button&quot; name=&quot;&quot; value=&quot;Lion Info&quot; onclick=&quot;sendEmail('lions');&quot; />
<p />
Click to get info on subject 2 &quot;tigers&quot;:
<input type=&quot;button&quot; name=&quot;&quot; value=&quot;Tiger Info&quot; onclick=&quot;sendEmail('tigers');&quot; />
<p />
Click to get info on subject 3 &quot;bears&quot;:
<input type=&quot;button&quot; name=&quot;&quot; value=&quot;Bear Info&quot; onclick=&quot;sendEmail('bears');&quot; />

<% Else %>

Thanks - you'll receive your info momentarily.
<p />
<a href=&quot;#&quot; onclick=&quot;history.go(-1);&quot;>BACK</a>

<% End If %>

</body>
</html>

You'll need a webserver that supports ASP (such as a Windows server running IIS) to use this example.

Hope this helps!

=============================================================================== ======================================

if (!succeed) try++
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top