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 email cdo message help

    Hello,

    I posted a similar message like this last week. This is something new that I can't figure out.

    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, e@d.com

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

    Currently, the email message send each student a separate email. However, it should send an email to students who have the same ID

    For example, the email should send to a@b.com and e@d.com on ONLY one message and the email should send to c@d.com one message.

    ID Email Date

    1 a@b.com 5/4/2011

    2 c@d.com 5/4/2011 1

    e@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' Group By Student_ID, Student_Email, dueDate; "
    
    oRs.Open strSQL, myConn
    
    %>
    
    <br /><h2>Student_Report Reminder</h2>
    
    <%
    
    Dim NewMailObj, strBody, sMail, aEmail
    
    aEmail = aEmail & sEmail & ","
    
    if not oRs.eof then
    
    do until oRs.eof
    
    sID = oRs("Student_ID")
    
    sEmail = oRs("Email")
    
    sDate = oRs("dueDate")
    
    aEmail = aEmail & sMail & ","
    
    
    
    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
    
    oRs.MoveNext
    
    loop
    
    End If
    
    %>

  2. #2
    SitePoint Addict itHighway's Avatar
    Join Date
    Jan 2008
    Location
    GUJ
    Posts
    270
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any group id or something in the database that can tell the system that user a@b.com and e@d.com belong to same group?

  3. #3
    Non-Member
    Join Date
    Jul 2008
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry to get you confused. What I mean is Department_ID.

    Student_id Dept_ID email
    1 1 1@2.com
    2 2 2@3.com
    3 1 3@4.com

    If there are 3 records that meet the query, then the message will send to students who have the same Dept_ID.

    1@2.com and 3@4.com have the same Dept_ID so they receive ONLY one message together, instead of each message separately. For 2@3.com is the only one so he/she will receive one message.

    Currently, the code sends out an email for each return record. How do I fix the code so that the email sends out for each department. For example, Dept 1 that has 2 students, there is ONLY one message sends out.

    If A and B are on the same Department, then the code should send ONE email to A and B.
    Currently, the code sends 2 email messages to each of them separately.


    If 5 departments with 3 students each:

    It should send 5 emails total with the emails going to the groups of the three student addresses in each department?

    Oh, I don't need Group By.
    select Student_ID, Student_Email + '@yahoo.com' AS Email from Students Where dueDate='5/4/2011';

    If I can get 2 records like this:

    1@2.com,3@4.com
    2@3.com

    Then, it will work.

    Thanks.


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
  •