Mailing App Duplicate problem...

Discussion in 'ASP General' started by @sh, Jul 6, 2006.

  1. @sh

    @sh Guest

    Guys,

    I've written an email sending script to mass send to our database - some of
    our subscribers are subscribed to multiple list, and so when selecting the
    entire database, I want to ensure I don't have Duplicates.

    To avoid this, I am selecting the recordset of all users, ordering by Email
    address, sending the email, moving onto the next record and then starting a
    loop to keep looping until the email address is different, but it doesn't
    work... see example below...

    -----------------------------------

    Do While NOT RS_RecipientsForCampaign.EOF

    SEND THE EMAIL HERE...

    RS_RecipientsForCampaign.MoveNext

    If NOT RS_RecipientsForCampaign.EOF Then
    ** Do While TheUsersEmailAddress =
    RS_RecipientsForCampaign("Email") AND NOT RS_RecipientsForCampaign.EOF
    RS_RecipientsForCampaign.MoveNext
    Loop
    End If

    Loop

    -----------------------------------

    When running, the script works fine, BUT I get an Unspecified error (I HATE
    that message) at the end of the script, pointing me to the line number
    marked with ** above.

    How can I cure this? I've tried everything but need a solution to amend this
    section of code that works!!

    Cheers, Ash
    @sh, Jul 6, 2006
    #1
    1. Advertising

  2. @sh

    @sh Guest

    Actually, sorry just to confirm, here is the exact error message...

    error '80020009'
    Exception occurred.
    blah.asp, line 799



    "@sh" <> wrote in message
    news:...
    > Guys,
    >
    > I've written an email sending script to mass send to our database - some
    > of our subscribers are subscribed to multiple list, and so when selecting
    > the entire database, I want to ensure I don't have Duplicates.
    >
    > To avoid this, I am selecting the recordset of all users, ordering by
    > Email address, sending the email, moving onto the next record and then
    > starting a loop to keep looping until the email address is different, but
    > it doesn't work... see example below...
    >
    > -----------------------------------
    >
    > Do While NOT RS_RecipientsForCampaign.EOF
    >
    > SEND THE EMAIL HERE...
    >
    > RS_RecipientsForCampaign.MoveNext
    >
    > If NOT RS_RecipientsForCampaign.EOF Then
    > ** Do While TheUsersEmailAddress =
    > RS_RecipientsForCampaign("Email") AND NOT RS_RecipientsForCampaign.EOF
    > RS_RecipientsForCampaign.MoveNext
    > Loop
    > End If
    >
    > Loop
    >
    > -----------------------------------
    >
    > When running, the script works fine, BUT I get an Unspecified error (I
    > HATE that message) at the end of the script, pointing me to the line
    > number marked with ** above.
    >
    > How can I cure this? I've tried everything but need a solution to amend
    > this section of code that works!!
    >
    > Cheers, Ash
    >
    @sh, Jul 6, 2006
    #2
    1. Advertising

  3. @sh wrote:
    > Guys,
    >
    > I've written an email sending script to mass send to our database -
    > some of our subscribers are subscribed to multiple list, and so when
    > selecting the entire database, I want to ensure I don't have
    > Duplicates.
    >
    > To avoid this, I am selecting the recordset of all users, ordering by
    > Email address, sending the email, moving onto the next record and
    > then starting a loop to keep looping until the email address is
    > different, but it doesn't work... see example below...
    >
    > -----------------------------------
    >
    > Do While NOT RS_RecipientsForCampaign.EOF
    >
    > SEND THE EMAIL HERE...
    >
    > RS_RecipientsForCampaign.MoveNext
    >
    > If NOT RS_RecipientsForCampaign.EOF Then
    > ** Do While TheUsersEmailAddress =
    > RS_RecipientsForCampaign("Email") AND NOT RS_RecipientsForCampaign.EOF
    > RS_RecipientsForCampaign.MoveNext
    > Loop
    > End If
    >
    > Loop
    >
    > -----------------------------------
    >
    > When running, the script works fine, BUT I get an Unspecified error
    > (I HATE that message) at the end of the script, pointing me to the
    > line number marked with ** above.
    >
    > How can I cure this? I've tried everything but need a solution to
    > amend this section of code that works!!
    >

    You should be able to construct a query that returns unique addresses.
    However, the details for how that would be done depend on the database
    type and version you are using (please always supply this information
    when requesting database-related help. It is almost always relevant)

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jul 6, 2006
    #3
  4. @sh

    @sh Guest

    > You should be able to construct a query that returns unique addresses.
    > However, the details for how that would be done depend on the database
    > type and version you are using (please always supply this information
    > when requesting database-related help. It is almost always relevant)


    Thanks for your reply. We're using SQLServer v7, I did consider how to
    return unique addresses, perhaps by using Distinct, but we also need
    alongside that the other details for the user, for example title, firstname,
    lastname etc.

    Surely there is a simple solution to get this script working? What am I
    missing?
    @sh, Jul 6, 2006
    #4
  5. @sh

    @sh Guest

    Re: Mailing App Duplicate problem... SOLVED!

    Just solved it myself, for anyone else with the same problem, you need to
    look into the 'Exit Do' function, VERY DAMN HANDY!!!!

    Final code bit now looks like this...

    Do While NOT RS_RecipientsForCampaign.EOF
    If (TheUsersEmailAddress <>
    RS_RecipientsForCampaign("Email")) Then
    Exit Do
    Else
    RS_RecipientsForCampaign.MoveNext
    End If
    Loop

    Cheers, @sh


    "@sh" <> wrote in message
    news:...
    >> You should be able to construct a query that returns unique addresses.
    >> However, the details for how that would be done depend on the database
    >> type and version you are using (please always supply this information
    >> when requesting database-related help. It is almost always relevant)

    >
    > Thanks for your reply. We're using SQLServer v7, I did consider how to
    > return unique addresses, perhaps by using Distinct, but we also need
    > alongside that the other details for the user, for example title,
    > firstname, lastname etc.
    >
    > Surely there is a simple solution to get this script working? What am I
    > missing?
    >
    @sh, Jul 6, 2006
    #5
  6. @sh wrote:
    >> You should be able to construct a query that returns unique
    >> addresses. However, the details for how that would be done depend on
    >> the database type and version you are using (please always supply
    >> this information when requesting database-related help. It is almost
    >> always relevant)

    >
    > Thanks for your reply. We're using SQLServer v7, I did consider how to
    > return unique addresses, perhaps by using Distinct, but we also need
    > alongside that the other details for the user, for example title,
    > firstname, lastname etc.


    Then use GROUP BY

    Of course, now I need to know something about your table's structure.
    However, something like:

    SELECT email, Max(title) title, Max(firstname) firstname,
    Max(lastname) lastname
    from table
    group by email

    >
    > Surely there is a simple solution to get this script working?

    Probably, but I wouldn't bother with this inefficient technique.
    Concentrate on retrieving the correct data from your database. Never
    retrieve more data than you are going to use.

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jul 6, 2006
    #6
  7. @sh

    @sh Guest

    Thanks for your help Bob, will look at reworking the SQL later on, got to
    just get the thing working for now ;o)

    Cheers, @sh
    @sh, Jul 6, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    476
    Jerry III
    Aug 11, 2003
  2. Riku Kosonen

    SMTP mailing problem (sending 1000 messages)

    Riku Kosonen, Jan 4, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    450
    Riku Kosonen
    Jan 5, 2005
  3. administrata

    problem with tutor mailing

    administrata, Feb 16, 2005, in forum: Python
    Replies:
    3
    Views:
    293
    Kartic
    Feb 16, 2005
  4. Replies:
    1
    Views:
    587
    Steve Holden
    Apr 30, 2005
  5. pkellner
    Replies:
    0
    Views:
    493
    pkellner
    Apr 27, 2007
Loading...

Share This Page