Solved

Validate an e-mail address while looping

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

861 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

25 Experts available now in Live!

Get 1:1 Help Now