Mailing App Duplicate problem...

@

@sh

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

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

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

Bob Barrows [MVP]

@sh said:
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)
 
@

@sh

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

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
 
B

Bob Barrows [MVP]

@sh said:
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.
 
@

@sh

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top