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

Help, can't get this asp page to show - what's wrong? 1

Status
Not open for further replies.

Steve54321

Technical User
Sep 29, 2001
11
US
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>

<%
Dim DATA_PATH, objDC, objRS, email, password, sendmail
'Maps to database. Change to your database path.
DATA_PATH=Server.Mappath("users.mdb")
' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30
objDC.Open "DBQ=" & DATA_PATH & ";Driver={Microsoft Access Driver (*.mdb)}; DriverId=25;MaxBufferSize=8192;Threads=20;", "admin", "password"
Set objRS = Server.CreateObject("ADODB.Recordset")
email=request.form("email")
'you may need to adjust this to suit your database
objRS.Open "SELECT * FROM my_users WHERE email = '" & email & "'", objDC, 0, 1
%>

<html>
<head>
<title>Forgotten Password</title>
</head>

<%
'checks if email address exists in the database before sending a message.
if objrs.EOF then
%>
<B><font color="red">
There is no account for <%=email%>.
</font></B>
<% Else %>


<%
'sets variables
email = request.form("email")
'chooses email and password from database that correspond to submitted email address.
email = objrs.Fields("email")
password = objrs.Fields("password")
Set sendmail = Server.CreateObject("CDO.NewMail")
'put the webmaster address here
sendmail.From = "webmaster@itradeplus.com"
'The mail is sent to the address entered in the previous page.
sendmail.To = email
'Enter the subject of your mail here
sendmail.Subject = "The Login Information You Requested"
'This is the content of thr message.
sendmail.Body = "The login Information you requested." & vbCrlf & vbCrlf _
& "email=" & email & vbCrlf _
& "Password=" & password & vbCrlf
'this sets mail priority.... 0=low 1=normal 2=high
sendmail.Importance = 2
sendmail.Send
%>

Your login information has been mailed to <%=email%>.<br>
You should receive it shortly.
<%
' Close Data Access Objects and free DB variables
objDC.Close
Set objRS = Nothing
Set objDC = Nothing
Set sendmail = Nothing
%><%end if%></html>
 
are you getting any errors? view source for anything hidden?
 
HTTP 500 - Internal server error & email is not sent
 
I have not had a chance to use the cdo.newmail object in ASP yet. I have use the cdo.message object. You are welcome to use this code. I have tested it works. Hopefully it will help you out.

<%
'Standard settings for email
'Sample code used found@ '-----------------------------------------------------------------
Const cdoSendUsingMethod = "Const cdoSendUsingPort = 2
Const cdoSMTPServer = "Const cdoSMTPServerPort ="Const cdoSMTPConnectionTimeout = "Const cdoSMTPAuthenticate = "Const cdoBasic = 1
Const cdoSendUserName = "Const cdoSendPassword = "'------------------------------------------------------------------
dim cn
dim rs
dim m_objCDOcon
dim Fields
dim m_objCDO
dim sEmail

Set m_objCDO = Server.Createobject("CDO.Message")
Set m_objCDOcon = Server.Createobject("CDO.Configuration")
set cn = Server.Createobject("ADODB.Connection")
set rs = Server.Createobject("ADODB.Recordset")

sEmail = Request.form("Email")

if sEmail = "" then
Response.write "Please complete form"
else
'Replace with your database connection information
with cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "c:\inetpub\ .Open
end with

rs.Open "Select * from users where Email = '" & sEmail & "'",cn,1,3
rs.MoveFirst

'Sending email notification
set Fields = m_objCDOcon.Fields

'Setting up Message parameters
with Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
'Replace with your SMTP server
.Item(cdoSMTPServer) = "mail.yourserver.net"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
'Only used if SMTP server requires Authentication
'.Item(cdoSMTPAuthenticate) = cdoBasic
'.Item(cdoSendUserName) = "UserName"
'.Item(cdoSendPassword) = "Password"
.Update
end with

'Passing parameters to message object
Set m_objCDO.Configuration = m_objCDOcon

With m_objCDO
'Replace with email you wish the message to be sent to
.To = sEmail
'Replace with email you wish the message to be from
.From = "Do@Not.Respond.net"
'Replace with subject
.Subject = "Forgotten Password"
'Replace with information you want to be sent
.HTMLBody = rs("Password")
.Send
End With

Response.write "Email has been sent<BR>"
Response.write sEmail
end if


%>

Please let me know if this helps.

Cassidy
 
I need the database connection to DSN-less, can I replace
'AAA with 'BBB and have it work correctly or is 'BBB incorrect coding - I am not familiar with this layout for referencing a database.

'AAA
'Replace with your database connection information
with cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "c:\inetpub\ .Open
end with

'BBB
'Replace with your database connection information
with cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = Data Source=" & Server.MapPath("\myfolder\mydatabase.mdb")
.Open
end with
 
No error now with the minor corrections below:

'Replace with your database connection information
with cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString =Server.MapPath("\myfolder\mydatabase.mdb")
.Open
end with
 
Now getting error '8004020f' at .Send line, any idea what's going wrong - email not being sent & error message?

With m_objCDO
'Replace with email you wish the message to be sent to
.To = sEmail
'Replace with email you wish the message to be from
.From = "Do@Not.Respond.net"
'Replace with subject
.Subject = "Forgotten Password"
'Replace with information you want to be sent
.HTMLBody = rs("Password")
.Send
End With
 
Sorry about the slow response. That error I generally get when I have a problem with the smtp server. Normally the server rejects a message.

In the place of sEmail hard code an address and see if it sends. Also type a physical message in the body of the email.

If it still doesn't send then check your server settings.

Let me know.

Cassidy
 
Also need to add if it does work then we need to check the database connection.

Let me know what you find out.

Thanks

Cassidy
 
Called my shared host & confirmed:

• SMTP Server is correct
• SMTP Server Port = 25
• SMTP server requires authentication
• User Name = User Name of pop account
• Password = Password of pop account

Gets error message below, I guest figuring out how to debug SMTP server problems is the next step – any suggestions?

CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/sendit2.asp, line 95
 
Sure. Use telnet to make connect to the smtp server. If you have Windows 2000 or XP go to a DOS prompt and type the following:

telnet smtpserver 25

If you get something that appears like the following:

220 mercury.iweb.lnh.net Microsoft ESMTP MAIL Service, Version: 5.0.2195.6713 re
ady at Wed, 12 May 2004 07:25:50 -0600

Then you have access to the server. If you timeout then it is a networking problem and we need to address that.

Let me know

Cassidy
 
Connection failed using telnet as you prescribed. I am using a web host. Even my email account is web based. My MS Outlook is by-passed and remains dormant. I am trying to email the password back to a subscriber upon request via asp. Code looks fine; web host agrees all is fine on their end. I am able to send and receive email between the web host email service and my personal email service. From my error message '80040213', I now know it is a SMTP mail server issue. As to what next step(s) to a solution - I am lost.
Change web host?
One recommendation says…

“CDO cannot authenticate. You will need to use another mail transport like ASPMail.”

Thanks for keeping with me this far.
You have provided more than expected.

Stephen
 
Called my shared host & confirmed:

•SMTP Server is correct
•SMTP Server Port = 25
•SMTP server requires authentication
•User Name = User Name of pop account
•Password = Password of pop account

Gets error message below for the code at bottom, I guess figuring out how to debug SMTP server problems is the next step – any suggestions on doing this, I'm lost?
Would ASPmail be a solution?

CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/sendit2.asp, line 95

'Setting up Message parameters
with Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
'Replace with your SMTP server
.Item(cdoSMTPServer) = "smtp.xyz.com"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
'Only used if SMTP server requires Authentication
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "UserName"
.Item(cdoSendPassword) = "Password"
.Update
end with

'Passing parameters to message object
Set m_objCDO.Configuration = m_objCDOcon

With m_objCDO
'Replace with email you wish the message to be sent to
.To = sEmail
'Replace with email you wish the message to be from
.From = "webmaster@xyz.com"
'Replace with subject
.Subject = "Forgotten Password"
'Replace with information you want to be sent
.HTMLBody = rs("Password")
.Send
End With

Response.write "Email has been sent<BR>"
Response.write sEmail
 
I had to go out of town on business. So first let me apopligize for not getting back sooner. What would be the next step would be to do a MX record lookup to see how they have their public information configured. If you can not telnet to the smtp port then you can not send mail via that server unless they open it up for relaying. If they relay that opens up a whole other can of worms on qualified domains.

If you need to do a MX record lookup just go to about any search engine and type MX loopkup. It will pull up a slew of places to do this. Then type in the search portion of the lookup your qualified domain. ie. xyz.com

This will pull any A level records they have for processing public information. There should be and entry for an IP address and port 25. That is where you want to try. If it is the same information you have then check to see if they require encrypted Authentication or certificates.

Finally if all else fails you can get a windows 2000 box, turn on SMTP, disable relaying, and setup a user login on a public IP address and use it.

Let me know what you find out.

CAssidy
 
Cassidy,
I finally got the code working perfectly, thanks to your ever persisting help. I hope others will find the post of value as I did.

In the end I made the two following changes:

Changed
.Item(cdoSendUsingMethod) = cdoSendUsing
To
.Item(cdoSendUsingMethod) = 1

And
Changed
.Item(cdoSMTPServer) = "smtp.xyz.com"
To
.Item(cdoSMTPServer) = "
All is fine now.
Thank You!
Stephen
 
I am glad that it worked out. Let me know if there is anything else in the future.

Thanks

Cassidy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top