Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Send email from form entry
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Send email from form entry

 Post Reply Post Reply
Author
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Topic: Send email from form entry
    Posted: 06 October 2003 at 6:08pm

I almost have this working except for a few bugs.  Basicly I want someone to enter their username and then the page will look up that entry and send the user their password to their email.  The problem I am having is specifying the TO Email based on the entry you get back from the DB and the Body containing that enties information.  Here is the code.  I highlighted the two lines in question. Any suggesstions?

Thanks

If Request.querystring("mode") = "get" then

'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("toddwoolums_site.mdb")

strUserName = Request.Form("txtUserName")

IF strUserName = "" then
 Response.Redirect"password.asp?mode=blank"
End If

'Create an ADO recordset object
Set rsGetPassword = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT username, password, email from tblUsers where username = '" & strUserName & "'"

'Open the recordset with the SQL query
rsGetPassword.Open strSQL, adoCon

'Reset server objects

If rsGetPassword.EOF then
 Response.Redirect"password.asp?mode=nouser"
End If

Dim strEmail
strEmail = rsGetPassword("email")

Response.Write ("Username is ")
Response.Write (rsGetPassword("username"))
Response.Write ("<br><br><br>")
Response.Write ("Password is ")
Response.Write (rsGetPassword("password"))
Response.Write ("<br><br><br>")
Response.Write ("Email is ")
Response.Write (rsGetPassword("email"))
Response.Write ("<br><br><br>")

'Dimension variables
Dim objCDOMail      'Holds the CDONTS NewMail Object
'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
'Who the e-mail is from
objCDOMail.From = "mine@email.com"
'Who the e-mail is sent to
objCDOMail.To = rsGetPassword("email")
'Set the subject of the e-mail
objCDOMail.Subject = "Lost Password"
'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0
'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0
'Set the main body of the e-mail
objCDOMail.Body = "Password is: '" & rsGetPassword("password") "'"
'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1
'Send the e-mail
objCDOMail.Send
'Close the server object
Set objCDOMail = Nothing

Set rsGetPassword = Nothing
Set adoCon = Nothing

End If

Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 6:18pm

So what's the problem???

<edit> I see one with this line:

objCDOMail.Body = "Password is: '" & rsGetPassword("password") "'"

should be:

objCDOMail.Body = "Password is: '" & rsGetPassword("password") & "'"



Edited by fernan82
FeRnAN
Back to Top
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 6:24pm

Ok now I get this error.  I am also going to note that this is on a windows 2003 server and I don't know if it has cdonts.  IS there an easier way to do this?

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/password.asp, line 100

800401f3

Back to Top
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 6:32pm

Ok I found a tutorial that might help. http://www.invisionportal.com/show_tutorial.asp?TutorialID=1 60  So I changed my code to look like this.   But I am getting this error now line 124 is marked

error '8004020f'

/password.asp, line 124

'Dimension variables
Dim objCDOSYSCon
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Set and update fields properties
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mydomain.com"
'SMTP port
objCDOSYSCon.Fields(" http://schemas.microsoft.com/cdo/configuration/smtpserverpor t")  = 25
'CDO Port
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Timeout
objCDOSYSCon.Fields(" http://schemas.microsoft.com/cdo/configuration/smtpconnectio ntimeout") = 60
objCDOSYSCon.Fields.Update

'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
'Who the e-mail is from
objCDOSYSMail.From = "mine@email.com"
'Who the e-mail is sent to
objCDOSYSMail.To = rsGetPassword("email")
'The subject of the e-mail
objCDOSYSMail.Subject = "Lost Password"
'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
objCDOSYSMail.HTMLBody = "Password is: '" & rsGetPassword("password") & "'"
'Send the e-mail
objCDOSYSMail.Send
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing



Edited by twooly
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 6:54pm

Ok, on the first one what is line 100? if it's this:

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

Then that means you don't have CDONTS registered on your server.

On the second one, make sure that you have an SMTP server, that you got the right address for your SMTP server and that you have permission to relay email on it. Also post the full error message.

 



Edited by fernan82
FeRnAN
Back to Top
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 7:22pm

Ok CDONTS wasn't installed. 

My Test box wasn't letting me send through the local SMTP.  That is fixed now.  Thanks for all your help and sorry for being a pain.  I guess that is why I am a newbie.

 

Thanks again

--Todd

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.