SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Jul 2008
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ASP CDO email message help please

    Hello,



    I created a script to remind students to turn in their reports. Whenever I open this page, the script runs and students will receive an email to remind them to turn in their reports.

    On this script, I got the emails in this format, a@b.com c@d.com



    The strMail should store these emails in this format: a@b.com, c@d.com, so that when I open this page, it will send to 2 students.



    Currently, the email message list only the first record even thought there are 2 records.



    It should list a table with 2 records as:



    ID Email Date

    1 a@b.com 5/4/2011

    2 c@d.com 5/4/2011



    Can anyone please help?



    Thanks very much!



    Code:
    <%
    
                            Set oRs = Server.CreateObject("adodb.recordset")
    
                            strSQL = "        select Student_ID, Student_Email + '@yahoo.com' AS Email from Students Where dueDate='5/4/2011'; "
    
                            oRs.Open strSQL, myConn
    
                %>
    
                <br /><h2>2-Days Trip Report Reminder</h2>
    
                <%
    
    Dim NewMailObj, strBody, sMail, aEmail
    
    aEmail = ""
    
    if not oRs.eof then
    
                do until oRs.eof
    
                            sID = oRs("Student_ID")
    
                            sEmail = oRs("Email")
    
                            sDate = oRs("dueDate")
    
                            aEmail = aEmail & sMail & ","
    
                            oRs.MoveNext
    
                loop
    
    End If
    
     
    
                Set NewMailObj = CreateObject("CDO.message")
    
                NewMailObj.From = "Student_Report"
    
                NewMailObj.To = aEmail
    
                NewMailObj.Subject = "Student Report"
    
                NewMailObj.HTMLBody = "Reminder for the following students:<br><br><table><tr><td>ID</td><td>Email</td><td>Date</td></tr><tr><td>"&sID&"</td><td>"&sEmail&"</td><td>"&sDate&"</td></tr></table>" & vbCrLf
    
                NewMailObj.Send
    
                end if
    
    %>

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    #1 I would have thought having the 2nd comma in aEmail would throw an error? Unless ...

    #2 Should a semi-colon ( ; ) be used as the separator instead of a comma ( , ) ?

    Either way, you need to strip the trailing separator:
    Code:
    aEmail = Left (aEmail, Len (aEmail)-1)
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    Non-Member
    Join Date
    Jul 2008
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It worked perfect.

    Thanks very much.


Bookmarks

Posting Permissions

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