Click to See Complete Forum and Search --> : Please someon help b4 i chuck the pc in the pond!!


HollyF
May 16th, 2005, 10:54 AM
Right - I've tried what feels like a million different scripts to create an auto emailer on an asp page.

As a basic asp page my form takes info and puts it onto a database (no problems so far......) This is uploaded and happily working accross our intranet. Now I start getting a nervous tick.....

The idea is that when the info is entered and the submit button is clicked the info will be put onto the database AND an email is created to the email address entered into one of the form fields (as tutor_email) with details of the other fields within the email ie: To. = tutor_email, bodytext = forename surname &"has contacted us and will not be attending lessons today".

Not to much to ask??

I've managed to produce this within a form in access but so far on my html page I'm stumped. I'm now dreaming in VB script and need someone to help before DoCmd Me = [scream] true!!

PramodsNair
May 17th, 2005, 07:42 AM
hey HollyF,

i think the following link will be of help to you

http://www.webwizguide.info/asp/tutorials/email_using_cdonts_tutorial.asp

HollyF
May 18th, 2005, 07:37 AM
Ta For that.

the tutorial has given me some excellent code for sending an email, but it only allows to send a standard email - I need to include in there form fields from the form - but i'm not sure how (I've tried exchanging = "me@somewhere" to T2, but this comes up with a scripting error).

My code for the whole page so far is:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>

<form method="POST" action="Scripting.asp" webbot-action="--WEBBOT-SELF--">
<p>&nbsp;</p>
<p>name <input type="text" name="T1" size="20"></p>
<p>Email <input type="text" name="T2" size="20"></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

<%
'Dimension variables
Dim objCDOMail

'Create the email server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

'Who the email is from
objCDOMail.From = frm.T2

'Who the email is to
objCDOMail.To = "h.feldberg@nbcol.ac.uk" I WANT THIS TO BE ENTERED FROM T2

'Set the subject of the email
objCDOMail.Subject = "Message from Student Absence Line"

'Set the email body format (0=HTML, 1=Text)
objCDOMail.BodyFormat = 1

'set the main body of the email
objCDOMail.Body = "Student has phoned up" I WANT TO INCLUDE FORM FIELDS HERE

'Importance of email (0=Low, 1=normal, 2=high)
objCDOMail.Importance = 2

'Send the email
objCDOMail.Send

'Close the server object
Set objCDOMail = Nothing
%>

</body>

</html>

PramodsNair
May 19th, 2005, 03:57 AM
Ok, Ok

use the Request.Form method in your ASP script

ex :

<form method="POST" action="Scripting.asp" webbot-action="--WEBBOT-SELF--">
<p>&nbsp;</p>
<p>name <input type="text" name="T1" size="20"></p>
<p>Email <input type="text" name="T2" size="20"></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

<%
'Dimension variables
Dim objCDOMail

'Create the email server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

'Who the email is from
objCDOMail.From = frm.T2

'Who the email is to
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'HERE IS THE CHANGED CODE

objCDOMail.To = Request.Form("T2")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Set the subject of the email
objCDOMail.Subject = "Message from Student Absence Line"

'Set the email body format (0=HTML, 1=Text)
objCDOMail.BodyFormat = 1

'set the main body of the email
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
objCDOMail.Body = Request.Form("yourformfieldname")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Importance of email (0=Low, 1=normal, 2=high)
objCDOMail.Importance = 2

'Send the email
objCDOMail.Send

'Close the server object
Set objCDOMail = Nothing
%>


I have enclosed changed code between
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Hopes this helps you to get that job done.