Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation emaling details from an access DB

    Hi i have a system to email users their password if they forget it.
    The data is stored in a access db.
    it reading in their userid from a textbox
    finds it in the DB
    then emails the "password" to the users registered "email"

    Code:
    <%
    'Dimension variables
    Dim adoCon 		'Database Connection Variable
    Dim strCon		'Holds the Database driver and the path and name of the database
    Dim rsCheckDB 	'Database Recordset Variable
    Dim strAccessDB 	'Holds the Access Database Name
    Dim strSQL			'Database query sring
    Dim strUserName2 	'Holds the user name
    
    'Initalise the strUserName2 variable
    strUserName2 = Request.Form("txtUserName2")
    
    'Check the database to see if user exsits
    'Initialise the strAccessDB variable with the name of the Access Database
    strAccessDB = "users"
    
    'Create a connection odject
    Set adoCon = Server.CreateObject("ADODB.Connection")
    			 
    'Database connection info and driver
    strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath(strAccessDB)
    
    'Set an active connection to the Connection object
    adoCon.Open strCon
    
    'Create a recordset object
    Set rsCheckDB = Server.CreateObject("ADODB.Recordset")
    
    'Initalise the strSQL variable with an SQL statement to query the database
    strSQL = "SELECT tblUsers.UserID, tblUsers.Password, tblUsers.Email FROM tblUsers WHERE tblUsers.UserID ='" & strUserName2 & "'"
    
    'Query the database
    rsCheckDB.Open strSQL, strCon
    
    'If the recordset finds a record for the username entered then read in the password for the user
    If NOT rsCheckDB.EOF Then
    		
    		' declare variables
    Dim EmailFrom
    Dim EmailTo
    Dim Subject
    
    ' get posted data into variables
    EmailFrom = "someemail@hotmail.com"
    EmailTo =  rsCheckDB("Email")
    Subject = "User Reminder Service"
    
    ' prepare email body text
    Dim Body
    Body = "Dear"& rsCheckDB("UserID")& VbCrLf & VbCrLf
    "This message has been sent to you because you requested it, if you did not request it please contact us as soon as possible." & VbCrLf
    & VbCrLf
    "The Details you requested are as follows:" & VbCrLf
    "Username:" rsCheckDB("UserID")& VbCrLf
    "Password" rsCheckDB("Password")& VbCrLf
    "If you still persist in haveing trouble accessing your 'client area' of the website, please contact us by email or phone."& VbCrLf
    & VbCrLf
    "Thank You" & VbCrLf
    "Support & VbCrLf
    
    ' send email 
    Dim mail
    Set mail = Server.CreateObject("CDONTS.NewMail") 
    mail.To = EmailTo
    mail.From = EmailFrom
    mail.Subject = Subject
    mail.Body = Body
    mail.Send 
    
    		'Close Objects before redirecting
    		Set adoCon = Nothing
    		Set strCon = Nothing
    		Set rsCheckDB = Nothing
    		'Redirect to the authorised user page and send the users name
    
    ' redirect to success page 
    Response.Redirect("../User_Reminded.htm")
    
    End If
    
    'Redirect to the unautorised user page
    Response.Redirect"unknown_user.htm"
    %>
    Last edited by Brandoe85; 09-12-2005 at 01:52 PM. Reason: user request

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Hi and welcome to the board!

    Thanks for showing your code. Not sure if there was a question in there somewhere. I did notice that you're using CDONTS.

    CDO is generally used instead of CDONTS on IIS 5 and after (actually the SMTP service within IIS) which is generally on servers after Win NT4 (although I think CDONTS is sometimes still supported too).

    Here's a quickie memo to myself about converting my old CDONTS code to CDO:

    o Change objCDONTS to be called objCDO (actually this is just a cosmetic change)

    o This:
    Set objCDONTS = Server.CreateObject("CDONTS.NewMail")

    Changed to this instead:
    Set objCDO = Server.CreateObject("CDO.Message")

    o This:
    objCDONTS.Body = strEmailBody

    Changed to this instead:
    objCDO.TextBody = strEmailBody

    o This removed:
    ' Importance.
    ' (0=Low, 1=Normal, 2=High)
    objCDONTS.Importance = 1
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,062
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Quote Originally Posted by Bullschmidt
    o This removed:
    ' Importance.
    ' (0=Low, 1=Normal, 2=High)
    objCDONTS.Importance = 1
    You can still set importance in CDO just use this


    Code:
    With objCDO.Fields 
     
            ' for Outlook: 
            .Item(cdoImportance) = cdoHigh  
            .Item(cdoPriority) = cdoPriorityUrgent  
     
            ' for Outlook Express: 
            .Item("urn:schemas:mailheader:X-Priority") = 1 
     
            .Update 
        End With

  • #4
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi miranda

    Can u tell me how to set Read reciept in CDONTS Emails

    Thanks

  • #5
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,062
    Thanks
    4
    Thanked 8 Times in 8 Posts
    in CDONTS
    objCDONTS.Value("Disposition-Notification-To") = "me@myisp.com"


    in CDO
    objCDO.Fields(cdoDispositionNotificationTo) = "me@myisp.com"
    objCDO.Fields(cdoReturnReceiptTo) = "me@myisp.com"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •