Moses912
05-29-2003, 10:44 PM
Hi guys! I'm trying to send an e-mail from an ASP page, using CDOSYS. However my site is not up yet and I'm running it on IIS, is it possible to actually send Email (for test puposes) while i don't have it up on an actual server. Here is my code: it doesn't produce any errors, but when I go to check the email address to where it was supposed to send the email, there is nothing there. Please Help!!
<% language="VBscript" %>
<%'Dimension variables
Dim Email
Dim rsEmailCheck 'Holds the recordset for the new record to be added
Dim strSQL1 'Holds the SQL query to query the database
Dim objCDOSYSCon
Dim UserId
Dim Password
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Set and update fields properties
'Out going SMTP server
'LOCAL HOST WILL HAVE TO BE CHANGED TO THE SMTP SERVER NAME IE. WWW.YOUSITE.COM
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
'SMTP port
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'CDO Port
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Timeout
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
Email=Request.Form("email")
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("site.mdb")
'Create an ADO recordset object
Set rsEmailCheck = Server.CreateObject("ADODB.Recordset")
strSQL1 = "SELECT * FROM tblREGISTRY WHERE Email = '"&Request.Form("email")&"';"
'Set the cursor type we are using so we can navigate through the recordset
rsEmailCheck.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsEmailCheck.LockType = 3
rsEmailCheck.Open strSQL1, adoCon
If rsEmailCheck.eof = true then
rsEmailCheck.Close
Set rsEmailCheck = Nothing
Set adoCon = Nothing
Session("UserEmail")="NotFound"
Response.Redirect "ForgotUserInfo.asp"
End If
Session("UserEmail")="Sent"
UserID=rsEmailCheck.Fields("UserID")
Password=rsEmailCheck.Fields("Password")
objCDOSYSMail.To = Email
objCDOSYSMail.From = "webmaster@devasp.com"
objCDOSYSMail.Subject = "Email"
objCDOSYSMail.HTMLBody = "Your User Id is" & UserID &" and your password is " & Password
'Send the e-mail
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
rsEmailCheck.Close
'Reset server objects
Set rsEmailCheck = Nothing
Set adoCon = Nothing
Response.Redirect "ForgotUserInfo.asp"
%>
<% language="VBscript" %>
<%'Dimension variables
Dim Email
Dim rsEmailCheck 'Holds the recordset for the new record to be added
Dim strSQL1 'Holds the SQL query to query the database
Dim objCDOSYSCon
Dim UserId
Dim Password
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Set and update fields properties
'Out going SMTP server
'LOCAL HOST WILL HAVE TO BE CHANGED TO THE SMTP SERVER NAME IE. WWW.YOUSITE.COM
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
'SMTP port
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'CDO Port
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Timeout
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields.Update
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
Email=Request.Form("email")
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("site.mdb")
'Create an ADO recordset object
Set rsEmailCheck = Server.CreateObject("ADODB.Recordset")
strSQL1 = "SELECT * FROM tblREGISTRY WHERE Email = '"&Request.Form("email")&"';"
'Set the cursor type we are using so we can navigate through the recordset
rsEmailCheck.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsEmailCheck.LockType = 3
rsEmailCheck.Open strSQL1, adoCon
If rsEmailCheck.eof = true then
rsEmailCheck.Close
Set rsEmailCheck = Nothing
Set adoCon = Nothing
Session("UserEmail")="NotFound"
Response.Redirect "ForgotUserInfo.asp"
End If
Session("UserEmail")="Sent"
UserID=rsEmailCheck.Fields("UserID")
Password=rsEmailCheck.Fields("Password")
objCDOSYSMail.To = Email
objCDOSYSMail.From = "webmaster@devasp.com"
objCDOSYSMail.Subject = "Email"
objCDOSYSMail.HTMLBody = "Your User Id is" & UserID &" and your password is " & Password
'Send the e-mail
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
rsEmailCheck.Close
'Reset server objects
Set rsEmailCheck = Nothing
Set adoCon = Nothing
Response.Redirect "ForgotUserInfo.asp"
%>