Solved

Validate an e-mail address while looping

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 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