Looping through email addresses. CFTRY/CFCATCH

I am building an email system that will be looping through a
list of email addresses in our database and sending mail via
CFMAIL. Alot of times, the email addresses are bad. i.e.: no
".com", a comma in the email address, bad characters etc. How can I
loop through the email addresses sending them out, but when CFMAIL
errors out because of a bad address, the loop continues on ignoring
the bad address. Can I do this with CFTRY/CFCATCH? Will
CFTRY/CFCATCH halt the process entirely or will it catch it then
continue on?

Cold Fusion has an isvalid function you can use to confirm
that any
given string is a properly formatted email address. You can
use this to
prevent improperly formatted addresses from getting into your
db in the
first place.
If ColdFusion was used to put the email address into the
database in the
first place. That is not always true. Some places have more
the one
application working with a given database.
Now using isValid to validate the address before attempting
to use it in
a <cfmail...> tag may provide some value, but would
still be comfortable
with wrapping the tag with a try catch. I just like to do so
whenever I
am playing with other protocols.

Similar Messages

Maybe you are looking for