Solved

Validate an e-mail address while looping

Posted on 2003-11-05
3
156 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 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