Solved

Validate an e-mail address while looping

Posted on 2003-11-05
3
153 Views
Last Modified: 2013-12-24
OK, it's me again.

Description of issue:
I am looping through a QUERY and I have a value #Domain#

Now these values have been pulled from a database where clients have entered a domain.  What I need to do is append the word "webmaster@" to the domain and send an e-mail.

The problem is sometimes they enter www.abc.com/default.php or redhat.com%20, etc. you get the point.

Now I have it all figured out (see below) except how to validate the "potential" e-mail to make sure it is correct so that I do not get an error.

I would like something like the "on error resume next" capabilities in .asp, to allow the code to continue, I would even except an exception statement.

As I stated before, these are already in a database, so there is no cleaning up that code.

Thanks,
-I remain

*****************************************
<CFQUERY name="DBRead" DATASOURCE="DBRead">
    SELECT Domain FROM DB
</CFQUERY>

<CFMAIL QUERY="DBREAD"

-----------------------
TO="Webmaster@#TRIM(Domain)#"
--RIGHT HERE I NEED TO MAKE SURE IT IS IN A VALID FORMAT.
-----------------------
FROM="ME@me.com"
SUBJECT="Request Info">
Dear Webmaster at #Domain#:

blah, blah, blah...
</CFMAIL>
*****************************************

0
Comment
Question by:turbosig
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
hart earned 125 total points
ID: 9686328
if u want to send emails to people who have entered
domains like redhat.com, hotmail.com etc.. only

then the following code will do the check

<CFQUERY name="DBRead" DATASOURCE="DBRead">
    SELECT Domain FROM DB
</CFQUERY>

<cfloop query="DBRead">
<cfif ListLen(trim(domain),'.') EQ 2 And ListFindNoCase(trim(domain),'com','.') neq 0>
    <cfmail from="me@me.com" to="webmaster@#trim(domain)#" subject="something" type="html">
         blah....
    </cfmail>
</cfif>
</cfloop>

but the above code will only work for someaddress.com

regards
Hart
0
 
LVL 2

Author Comment

by:turbosig
ID: 9686360
Thanks.
0
 
LVL 11

Expert Comment

by:hart
ID: 9686380
u r welcome :-)

Regards
Hart
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now