Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old August 5th, 2004, 04:48 PM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

Alright, I want when you go to the page for it to load up all the check boxes and such. Then when you hit submit it'll email everything and just go to a page saying success or some such. Here's the code I have of yours but it says an expected end of statement on line 29 is the error. If I take out the code you gave me and uncomment the several lines below it works fine and displays all the correct info. Did I put this stuff in the right spot? Also how would I make it so it emails on the submit? I think the problem here is that you have to click a submit button to make the check boxes appear or am I wrong?

<%Option Explicit%>
<HTML>
<HEAD>
<TITLE>Testing</TITLE>
</HEAD>
<BODY>

<%
    dim cn, sql, rs
    Set cn = CreateObject("ADODB.Connection")

    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=c:\inetpub\database\ftp.mdb;" & _
        "Jet OLEDB:System Database=\\matrix\database\dent32\dent32.mdw" , _
        "Hidden", "Hidden"

    set rs = server.createobject("adodb.recordset")
    sql = "SELECT PASSWORD.Password, PASSWORD.IsCurrent, PASSWORD.Assigned, PASSWORD.ID, CLIENT_CONTACTS.[CONTACT EMAIL], CLIENT.[CLIENT NAME] " & _
          "FROM [PASSWORD], CLIENT_CONTACTS, CLIENT " & _
              "WHERE (((PASSWORD.IsCurrent)=-1) AND ((PASSWORD.Assigned)=#4/16/04#) AND ((PASSWORD.ID)=[CLIENT_CONTACTS].[CLIENT ID] And (PASSWORD.ID)=[CLIENT].[CLIENT ID]));"

    response.write("<h5>Check the check box if you would like to email the client his username and password</h5>")
    response.write("<b>[u]Client Name</u> [u]ID</u> [u]Contact Email</u> </b>") & "<br>" & "<br>"

    rs.Open sql, cn

    strHTML=strHTML & "<form name='frm1' action='test.asp' method='post'>"
    while not rs.eof
            strHTML=strHTML & "<input type='checkbox' name='chkEmails' value='" & rs("CONTACT EMAIL") & "_" rs("CLIENT NAME") & "_" & rs(Password) & "'>"
        rs.movenext
    wend

    strHTML=strHTML & "</form>"
    Response.write strHTML

' if not rs.eof then
' do while not rs.eof
' response.write rs("CLIENT NAME") & " " & _
' rs("ID") & " " & _
' rs("CONTACT EMAIL") & "<br>"
' rs.movenext
' loop
' end if
    rs.close
    set rs = nothing

%>
</BODY>
</HTML>

Reply With Quote
  #12 (permalink)  
Old August 6th, 2004, 11:30 AM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

This should work without the second part that has the emails right? Cause I don't have that in but still doesn't work. Above is the code I have.

Reply With Quote
  #13 (permalink)  
Old August 6th, 2004, 11:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

No, you don't have to click submit button to display the check boxes.
Just change those line as given below. Also you don't need the lines that are commented in your previous post.

    
Code:
Response.write "<form name='frm1' action='test.asp' method='post'>"
Code:
    while not rs.eof
            Response.write "<input type='checkbox' name='chkEmails' value='" & rs("CONTACT EMAIL") & "_" rs("CLIENT NAME") & "_" & rs(Password) & "'>"
        rs.movenext
    wend

    Response.write "</form>"
    'Response.write strHTML
    As per this code, your form now submits to test.asp
So add the remaining of my suggested code in test.asp...
Code:
Dim arrEmails

arrEmails = Split(Request("chkEmails"))

for j=0 to Ubound(arrEmails)
    arrTemp=split(arrEmails(j),"_")
    strEmail=arrTemp(0)
    strUserName=arrTemp(1)
    strPassword=arrTemp(2)
    objMail.to=strEmail
    'Do your Mailing code here for every strEmail.
next
Hope this explains.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #14 (permalink)  
Old August 9th, 2004, 11:10 AM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

I'm not sure I'm getting this right. I have what you put to replace the old stuff. Code is following and if its right I still get the same error on line 29 about an expected end of statement

<%Option Explicit%>
<HTML>
<HEAD>
<TITLE>Testing</TITLE>
</HEAD>
<BODY>

<%
    dim cn, sql, rs
    Set cn = CreateObject("ADODB.Connection")

    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=c:\inetpub\database\ftp.mdb;" & _
        "Jet OLEDB:System Database=\\matrix\database\dent32\dent32.mdw" , _
        "AdamI", "telescope"

    set rs = server.createobject("adodb.recordset")
    sql = "SELECT PASSWORD.Password, PASSWORD.IsCurrent, PASSWORD.Assigned, PASSWORD.ID, CLIENT_CONTACTS.[CONTACT EMAIL], CLIENT.[CLIENT NAME] " & _
          "FROM [PASSWORD], CLIENT_CONTACTS, CLIENT " & _
              "WHERE (((PASSWORD.IsCurrent)=-1) AND ((PASSWORD.Assigned)=#4/16/04#) AND ((PASSWORD.ID)=[CLIENT_CONTACTS].[CLIENT ID] And (PASSWORD.ID)=[CLIENT].[CLIENT ID]));"

    response.write("<h5>Check the check box if you would like to email the client his username and password</h5>")
    response.write("<b>[u]Client Name</u> [u]ID</u> [u]Contact Email</u> </b>") & "<br>" & "<br>"

    rs.Open sql, cn

    Response.write "<form name='frm1' action='test.asp' method='post'>"
        while not rs.eof
                Response.write "<input type='checkbox' name='chkEmails' value='" & rs("CONTACT EMAIL") & "_" rs("CLIENT NAME") & "_" & rs(Password) & "'>"
            rs.movenext
        wend

        Response.write "</form>"
       'Response.write strHTML
        rs.close
        set rs = nothing

%>
</BODY>
</HTML>

Reply With Quote
  #15 (permalink)  
Old August 9th, 2004, 10:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

What is there in line number 29?

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #16 (permalink)  
Old August 9th, 2004, 10:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

I just noticed that. It was my bad. Sory about that.

& is missing in there, also QUOTEs were missing around password in rs(Password). Change it to this.
Code:
Response.write "<input type='checkbox' name='chkEmails' value='" & rs("CONTACT EMAIL") & "_" & rs("CLIENT NAME") & "_" & rs("Password") & "'>"
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #17 (permalink)  
Old August 10th, 2004, 09:41 AM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

Alright, I got the check boxes working. Now how do I make it email when they hit a send button? I'll also need to make the send button and where does the code go? Following is the code that I think should work with some minor fixes. Also, what will this do if there is no email present? There are several of those records included. Will it just pass over? Oh, the "ID" should be the 'strLogin', the 'strName' should be the "CLIENT NAME" and the 'strPassword' should be "Password". I'm not sure if this is how its set up or how you put it in but thats how it should be set up.

Dim arrEmails

arrEmails = Split(Request("chkEmails"))

for j=0 to Ubound(arrEmails)
    arrTemp=split(arrEmails(j),"_")
    strEmail=arrTemp(0)
    strUserName=arrTemp(1)
    strPassword=arrTemp(2)
    objMail.To=strEmail
    objMail.From= "<hidden>@<hidden>.com"
    objMail.Subject= "Password Change"
    objMail.Body= "Hello 'strName'. This email is to inform you that your password has changed. Your login is 'strLogin'. Your new password is 'strPassword'. Please make a note of this in your records. If you have any problems please contact Data Services."
    objMail.AttachFile "\\DOYLE\inetpub\wwwroot\adamstuff\log.pdf"
    objMail.Send
next

Reply With Quote
  #18 (permalink)  
Old August 10th, 2004, 09:47 AM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

Just an addition to the above. Can it be made so that when you hit send it just goes to a new page that I can design. We'll call it success.html that just says, "Your emails have been sent." The url will be \\DOYLE\inetpub\wwwroot\adamstuff\success.html. So when you hit the send button, it will send an email to all those boxes that are checked then take you to a page that says the mails have been sent? Thanks. Of course if it gets an error it should say something like "There was a problem sending your emails. Please contact Data Services for more information." or some such. Thanks.

Reply With Quote
  #19 (permalink)  
Old August 10th, 2004, 09:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, this code should work with some fixes as marked below in blue.

Code:
Dim arrEmails, strSelectedDetails, objMail
strSelectedDetails = Request.Form("chkEmails")

If len(trim(strSelectedDetails))>0 then
    Set objMail = Server.CreateObject("CDONTS.NewMail")
    arrEmails = Split(strSelectedDetails)
    for j=0 to Ubound(arrEmails)
        arrTemp=split(arrEmails(j),"_")
        strEmail=arrTemp(0)
        strUserName=arrTemp(1)
        strPassword=arrTemp(2)
        objMail.To=strEmail
        objMail.From= "<hidden>@<hidden>.com"
        objMail.Subject= "Password Change"
        objMail.Body= "Hello " & strName & ", This email is to inform you that your password has changed. Your login is " & strLogin & ". Your new password is " & strPassword & ". Please make a note of this in your records. If you have any problems please contact Data Services."
        objMail.AttachFile server.mappath("log.pdf"), "CustomizedAttachementName.pdf"
        'The one marked in red is optional, that lets you name your attachment the way you want. 
        'But Extension should be the same as that your attachment file.
        objMail.Send
    next
Set objMail = nothing
Response.Redirect("Success.asp?MailSentTo=" & strSelectedDetails)
Else
    Response.Write "No Selection made for sending emails"
End If
Here I am not sure what you refer to as ID should the strLogin. Is that EmailID or something else. If that is something else, then that too should be constructed along with the "_" separated string when form is submitted.

Your Success.asp file should have something like.

Code:
<%
strSelectedDetails = Request.QueryString("MailsSentTo")
If len(trim(strSelectedDetails))>0 then
    Response.write "Mails have been sent to the following Email address(es)<br>"
    arrEmails = Split(strSelectedDetails)
    For i = 0 to UBound(arrEmails)
        Response.Write arrEmails(i) & "<br>"
    Next
End If
%>
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #20 (permalink)  
Old August 12th, 2004, 01:19 AM
Authorized User
 
Join Date: Jul 2004
Location: Chicago, , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Night_Zero
Default

Alright. I need to make it so this happens when you click a send button. How do I make the send button then add this code into it? Also, does it just go anywhere after the other stuff?

Lastly I don't really get how your code works when making the temp files for password username and such. The password should obviously be their password which is gotten from Password in the table and called strPassword. The ID which should be their username should be the ID and is called strLogin. The name should be their CLIENT NAME which I called strName. And strEmail should obviously be their email.

Oh, and one more thing. You never answered what this program would do if no email address was listed for a particular client. Will it just skip over it? Even if they check it, what will happen?

That should be all for now. Thanks.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop over check boxes sams ASP.NET 1.0 and 1.1 Professional 5 July 17th, 2007 06:26 AM
Check Boxes Allan320 Access VBA 3 June 2nd, 2006 05:45 AM
Using check boxes to filter dstein4d Access VBA 13 January 25th, 2006 07:50 PM
Disable Check Boxes sweet4511 VB How-To 22 July 19th, 2005 03:53 PM
Getting value of Dynamic Check boxes kathryne Classic ASP Databases 3 March 19th, 2004 05:44 AM



All times are GMT -4. The time now is 01:32 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.