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

ASPEmail and Requesting from forms....

Status
Not open for further replies.

Dostani

MIS
Jul 26, 2002
60
US
I am currently using ASPEmail and I at a loss I have built a shopping cart with to functions - one to email the order to the company and email a conformation to the shopper. No where that I understand in the docs allows to use request.form("email") to supply the address for sending to the client. The docs state that you can not use an "=" applied to the methods so my question is, how then does one do this trick using ASPEmail. No other is available on the host. Why ???

Thanks in advance

 
I forget how aspEmail was in this regards. But where ASPEmail has

Mail.Host = "mail.mycompany.com"

have you tried

Mail.Host = request.form("email") ? "Damn the torpedoes, full speed ahead!"

-Adm. James Farragut

Stuart
 
Actually yes and no. The problem relies on documentation vs implementation. If you read the ASPEmail docs is states you can not use the method Mail.AddAddress with an "=" sign then to add it states you can not with any of the methods. So I am at a loss.????

 
lol ok, talk about contradiction.

ok, well what happens when you try what I put above?

see what error messages it gives you - and we can narrow it from there.

btw - to gain better error messages, in IE, click tools, options, Advanced tab - Uncheck the box next to "Show friendly HTTP error messages" "Damn the torpedoes, full speed ahead!"

-Adm. James Farragut

Stuart
 
Did you ever get it resolved as I am experience a similar proble. Grateful you let me know how you resolved it.
 
whats the problem lin? "Never underestimate the power of determination"

Stuart
 
Stuart - your above suggestion to change the Mail.Host to request.form("email"), did not send the email for me but did take the action on the form.

I have overcome it by writing the email addresses to a database and pulling in a variable from the database to send the email to the person.

However I would still liek to know if ASPEmail can in fact take the email address someone has submitted in a form and if you can set an auto email to go back to them. All the examples I have found send the email to the company but no confirmation email can be sent to the submitter.

Hope this explains what I am trying to do.

Thanks. Linda
 
ok - will need to see your code for this. but you'd want something similiar to below. - make sure that this is page two. Page one submits to page two where you have this code.
and make sure that request.form("email") is indeed the correct email form field - and that your using form action="post"

<%
Set Mail = Server.CreateObject(&quot;Persits.MailSender&quot;)
Mail.Host = &quot;mail.mydomain.com&quot;
Mail.From = &quot;sales@mydomain.com&quot;
Mail.FromName = &quot;My Domain Sales&quot;
Mail.AddAddress request.form(&quot;email&quot;)
Mail.AddReplyTo &quot;info@mydomain.com&quot;

Mail.Subject = &quot;Thanks for ordering our hot cakes!&quot;
Mail.Body = &quot;Dear Sir:&quot; & Chr(13) & Chr(10) & _
&quot;Thank you for your business.&quot;

On Error Resume Next
Mail.Send
If Err <> 0 Then
Response.Write &quot;Error encountered: &quot; & Err.Description
End If
%>


&quot;Never underestimate the power of determination&quot;

Stuart
 
Hi Stuart

thank you - I have got it to work withthe above. However wonder if you could help me by looking at the undernoted code. My error handling in directing it to an unauthorised user page does not seem to work if their name is not in the database. Also if you type in a name in that is in the database in lower case the error handling works - it is the database as title case ie Joe Bloggs.

Can you see a way that it could accept any case ie block, title or lower.

Thanks for your help.

Linda

<%
'Dimension variables
Dim adoCon 'Database Connection Variable
Dim strCon 'Holds the Database driver and the path and name of the database
Dim rsPassword 'Database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL 'Database query sring
Dim strname 'Holds the user name

Dim strpassword 'Holds the user's password

'Initalise the variables from the form

'Get variables from form
email = request.form(&quot;email&quot;)
strname = request.form(&quot;name&quot;)


'Check the database to see if user exsits and read in their password from database
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = &quot;users&quot;

'Create a connection odject
Set adoCon = Server.CreateObject(&quot;ADODB.Connection&quot;)

'Database connection info and driver
strCon = &quot;DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=&quot; & Server.MapPath(strAccessDB)

'Set an active connection to the Connection object
adoCon.Open strCon

'Create a recordset object
Set rsPassword = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = &quot;SELECT * FROM tblUsers WHERE tblUsers.UserID = '&quot; & strname & &quot;'&quot;


'Query the database
rsPassword.Open strSQL, strCon
strpassword = rsPassword(&quot;Password&quot;)
'stremail = rsPassword(&quot;email&quot;)

'If the recordset finds a record for the username entered then read in the password for the user
If NOT rsPassword.EOF Then

'Read in the user name for the user from the database
If (Request.Form(&quot;name&quot;)) = rsPassword(&quot;UserID&quot;) Then

'If the user name is valid then set the session variable to True
Session(&quot;blnIsUserGood&quot;) = True

'Close Objects before redirecting
Set adoCon = Nothing
Set strCon = Nothing
Set rsPassword = Nothing

%>


<%
'Send the auto email using ASPemail
Set Mail = Server.CreateObject(&quot;Persits.MailSender&quot;)
Mail.Host = &quot;mail.corpex.com&quot;
'Mail.Host = &quot;mail.lincscot.co.uk&quot;
Mail.From = &quot;password@lincscot.co.uk&quot;
Mail.FromName = &quot;LINC Scotland&quot;
'Mail.AddAddress request.form(&quot;email&quot;)
Mail.AddAddress stremail
Mail.AddBCC &quot;linda.clark@lincscot.co.uk&quot;
Mail.AddReplyTo &quot;password@lincscot.co.uk&quot;
Mail.Subject = &quot;Password Reminder&quot;

BodyMsg = &quot;222You requested to be reminded of your password in order to gain access to the members area of our website This is as detailed below: &quot; + Chr(10) + Chr(10)
BodyMsg = BodyMsg + &quot;Name: &quot; & strname & Chr(10) + Chr(10)
BodyMsg = BodyMsg + &quot;Password: &quot; & strpassword & Chr(10) + Chr(10)
Mail.Body = BodyMsg

On Error Resume Next
Mail.Send

%>

<%

'Redirect to the authorised user page and send the users name
Response.Redirect&quot;password_email_confirmation.htm&quot;
End If
End If

'Close Objects
Set adoCon = Nothing
Set strCon = Nothing
Set rsPassword = Nothing

'If the script is still running then the user must not be authorised
Session(&quot;blnIsUserGood&quot;) = False

'Redirect to the unautorised user page
Response.Redirect&quot;unauthorised_password_page.htm&quot;
%>
 
Hi Linda,

Lets see if we can clean it up a little bit.
Replace your code with this code - and let me know the outcome. case should not matter unless you've specified that. You can always force lowercase on the form however.


<%
'Dimension variables
Dim strCon 'Holds the Database driver and the path
and name of the database
Dim rsPassword 'Database Recordset Variable
Dim strAccessDB 'Holds the Access Database Name
Dim strSQL 'Database query sring
Dim strname 'Holds the user name
Dim strpassword 'Holds the user's password

'Initalise the variables from the form

'Get variables from form
stremail = request.form(&quot;email&quot;)
strname = request.form(&quot;name&quot;)

'Database Name, connection info and driver
strAccessDB = &quot;users&quot;
strCon = &quot;DRIVER={Microsoft Access Driver
(*.mdb)};uid=;pwd=letmein; DBQ=&quot; & Server.MapPath
(strAccessDB)

'Create a recordset object
Set rsPassword = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'Initalise the strSQL variable with an SQL statement to
query the database
strSQL = &quot;SELECT * FROM tblUsers WHERE tblUsers.UserID = '&quot;
& strname & &quot;'&quot;


'Query the database
rsPassword.Open strSQL, strCon


'If the recordset finds a record for the username entered
then read in the password for the user
If NOT rsPassword.EOF Then
strpassword = rsPassword(&quot;Password&quot;)


'Send the auto email using ASPemail
Set Mail = Server.CreateObject(&quot;Persits.MailSender&quot;)
Mail.Host = &quot;mail.corpex.com&quot;
'Mail.Host = &quot;mail.lincscot.co.uk&quot;
Mail.From = &quot;password@lincscot.co.uk&quot;
Mail.FromName = &quot;LINC Scotland&quot;
'Mail.AddAddress request.form(&quot;email&quot;)
Mail.AddAddress stremail
Mail.AddBCC &quot;linda.clark@lincscot.co.uk&quot;
Mail.AddReplyTo &quot;password@lincscot.co.uk&quot;
Mail.Subject = &quot;Password Reminder&quot;

BodyMsg = &quot;222You requested to be reminded of your password
in order to gain access to the members area of our website
This is as detailed below: &quot; + Chr(10)
+ Chr(10)
BodyMsg = BodyMsg + &quot;Name: &quot; & strname & Chr(10) +
Chr(10)
BodyMsg = BodyMsg + &quot;Password: &quot; & strpassword & Chr
(10) + Chr(10)
Mail.Body = BodyMsg

On Error Resume Next
Mail.Send
if Err <>0 Then
response.write &quot;Error encountered: &quot; & Err.Description
End If
Response.Redirect (&quot;password_email_confirmation.htm&quot;)
%>

<% ELSE
'Close Objects
Set strCon = Nothing
rsPassword.close
Set rsPassword = Nothing
'redirect due to user not being valid
response.redirect (&quot;unauthorised_password_page.htm&quot;)
End IF
%>





&quot;Never underestimate the power of determination&quot;

Stuart
 
Stuart, Thank you - have got it working all I had to do was put in the line

stremail = rsPassword(&quot;email&quot;)
in order to send the email from that listed in the database.

Many thanks for tidying up my code.

Have a super Christmas Break and hope Santa is good to you.

Linda
 
ahhh - I uhhhh knew that [2thumbsup]

Have a great Christmas also. &quot;Never underestimate the power of determination&quot;

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top