[]\`|"> [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => BKBK [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 12 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> CFTRY inside a CFOUTPUT loop - Coldfusion - Advanced Techniques

CFTRY inside a CFOUTPUT loop - Coldfusion - Advanced Techniques

I am trying to send an email message with CFMAIL to about 6500 people. Unfortunately, the data is not very clean. There are control characters and many other characters that do not belong in an email address (eg. more than one at sign (), forward and backward slashes, less than signs (<) and greater than signs (>). I first wrote a program that searches for bad characters in an email address but there are too many to get them all in the program. So now I'm trying to catch the errors with CFTRY and the program is going through a ...

Sponsored Links
  1. #1

    Default CFTRY inside a CFOUTPUT loop

    I am trying to send an email message with CFMAIL to about 6500 people.
    Unfortunately, the data is not very clean. There are control characters and
    many other characters that do not belong in an email address (eg. more than one
    at sign (), forward and backward slashes, less than signs (<) and greater than
    signs (>).

    I first wrote a program that searches for bad characters in an email address
    but there are too many to get them all in the program. So now I'm trying to
    catch the errors with CFTRY and the program is going through a CFOUTPUT loop of
    all the addressees. But, when the CFTRY traps an error, the program ends. It
    does not go back to the CFOUTPUT loop to continue finding other addresses that
    are not acceptable to CFMAIL.

    Any help solving the problem would be greatly appreciated.

    Thanks,

    Mike

    Sponsored Links
    Mike.Tennor Guest

  2. #2

    Default Re: CFTRY inside a CFOUTPUT loop

    see if anything in http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=3&threadid=1024162 threaad helps.

    PaulH Guest

  3. #3

    Default Re: CFTRY inside a CFOUTPUT loop

    > I am trying to send an email message with CFMAIL to about 6500 people. 
    and 
    than one 
    than 
    address 
    to 
    loop of 
    It 
    that 

    You could use the isValid function before sending the e-mail (cfmx7 only
    though):

    <cfloop query="emails">
    <cfif isValid("email", email_address)>
    <cfmail to="#email_address#">
    ....
    </cfmail>
    </cfif>
    </cfloop>

    --
    <mack />


    Neculai Guest

  4. #4

    Default Re: CFTRY inside a CFOUTPUT loop

    >... You could use the isValid function
    Thanks for the info, Neculai. Just checked out isValid().
    Wow, don't you just love Coldfusion.
    BKBK Guest

  5. #5

    Default Re: CFTRY inside a CFOUTPUT loop

    I am running Cold Fusion MX 6.1. The isValid function sounds great but it doesn't work with this version of Cold Fusion. Do you have any other suggestions.

    Thanks,

    Mike
    Mike.Tennor Guest

  6. #6

    Default Re: CFTRY inside a CFOUTPUT loop

    >... I am running Cold Fusion MX 6.1. The isValid function sounds great but it 
    Didn't you have a look at the link PaulH gave you? It'll surely
    put some lead in your pencil.


    BKBK Guest

  7. #7

    Default Re: CFTRY inside a CFOUTPUT loop

    There are no suggestions I can see from Paul. He gave me a link to another forum. Please advise.
    Mike.Tennor Guest

  8. #8

    Default Re: CFTRY inside a CFOUTPUT loop

    What error type did you put in cfcatch type? Make sure you did not put cfabort after or <cflocation URL... addtoken="no">

    CF_Oracle Guest

  9. #9

    Default Re: CFTRY inside a CFOUTPUT loop

    bkbk, there's nothing difficult about the code i posted in that other thread,
    it's simple & straight forward. it's certainly nothing as melodramatic as your
    statements.

    Mike.Tennor, did you bother to read that other thread?

    PaulH Guest

  10. #10

    Default Re: CFTRY inside a CFOUTPUT loop

    Paul,

    I did not notice the hyperlink on the work "this" in your first posting. I
    just read this thread and the suggestions look good. I'll try them. Sorry - my
    fault. The use of cascading style sheets sometimes make hyperlinks invisible
    until they are first clicked.

    Mike

    MikeTennor Guest

  11. #11

    Default Re: CFTRY inside a CFOUTPUT loop

    >... it's simple & straight forward.
    For you, not necessarily for the rest of us, mere CF hacks. Not many CF
    developers venture into Javax and Exception land.
     
    Ha, ha, make 'em suffer daddy, and make 'em suffer in bold type.


    BKBK Guest

  12. #12

    Default Re: CFTRY inside a CFOUTPUT loop

    >... I am running Cold Fusion MX 6.1. The isValid function sounds great but 
    suggestions.

    Hi, Mike, does this tickle your fancy?





    <!---
    Component for e-mail validation.
    --->
    <cfcomponent displayname="emailValidator" hint="Contains method for email
    validation.">
    <cffunction name="emValidator" output="No" returntype="struct">
    <cfargument name="clientEmail" type="string" required="Yes">
    <cfset variables.email = Trim("#arguments.clientEmail#")>
    <cfset emailCheck = StructNew()>
    <cfset emailCheck.status = false>
    <cfif Len(variables.email) EQ 0>
    <cfset emailCheck.message = "You must give an e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    <cfif Len(variables.email) LT 6>
    <cfset emailCheck.message = "Invalid e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    <!--- There may not be more than one symbol, it may not be at beginning,
    be missing or be less than 4 characters from the end --->
    <cfset v1 = FindNoCase("",#ReplaceNoCase(variables.email,"", "","one")#)>
    <cfset v2 = Left(variables.email,1)>
    <cfset v3 = FindNoCase("", variables.email)>
    <cfset v4 = FindNoCase("",#Right(variables.email,4)#)>
    <cfif (#v1# NEQ 0) OR (#v2# IS "") OR (#v3# EQ 0) OR (#v4# NEQ 0)>
    <cfset emailCheck.message = "Invalid e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    <!--- E-mail addresses must have at least one dot, and it may not be at
    beginning or less than
    2 characters from the end --->
    <cfset v5 = FindNoCase(".", variables.email)>
    <cfset v6 = FindNoCase(".",#Right(variables.email,2)#)>
    <cfif (#v5# EQ 0) OR (#v6# NEQ 0)>
    <cfset emailCheck.message = "Invalid e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    <!--- Two dots or a dot and may not be side by side --->
    <cfif (#FindNoCase("..", variables.email)# NEQ 0) OR (#FindNoCase(".",
    variables.email)# NEQ 0) OR (#FindNoCase(".", variables.email)# NEQ 0)>
    <cfset emailCheck.message = "Invalid e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    <!--- There must be at least one dot between and the end --->
    <cfset domain = #ListGetAt(variables.email,2,"")#>
    <cfif #FindNoCase(".",domain)# EQ 0>
    <cfset emailCheck.message = "Invalid e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    <!--- No spaces in between --->
    <cfif FindNoCase(" ",variables.email) NEQ 0>
    <cfset emailCheck.message = "An e-mail address may not contain spaces.">
    <cfreturn emailCheck>
    </cfif>
    <!--- An e-mail address may not contain any of these characters:
    !"#$%(),:;<>[]\`|--->
    <cfset illegalString = """##!$%(),:;<>[]\`|">
    <cfif #FindOneOf(illegalString,variables.email)# NEQ 0>
    <cfset emailCheck.message = "Invalid e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    <!--- /*Top Level Domain must have 2,3 or 4 characters,
    and must consist only of letters, e.g. nl,com,org --->
    <cfset m = ListLen(variables.email,".")>
    <cfset v7 = ListGetAt(variables.email,#m#,".")>
    <cfset v8 = REFindNoCase("[^[:alpha:]]",v7,1,false)>
    <cfif (#Len(v7)# LT 2) OR (#Len(v7)# GT 4) OR (#v8# NEQ 0)>
    <cfset emailCheck.message = "Invalid e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    <!--- The blocks between the dots in a domain name, i.e. the sets of
    characters
    between the and the Top Level Domain, are called "labels" in DNS
    parlance.
    According to one DNS rule, each label must start with a number or letter
    and a
    label may not have more than 63 characters --->
    <cfset v9 = ListGetAt(variables.email,2,"")>
    <cfset nrOfLabels = ListLen(v9,".")-1>
    <cfloop index="i" from="1" to=#nrOfLabels#>
    <cfset label = ListGetAt(v9,i,".")>
    <cfset firstLabelChar = #Left(label,1)#>
    <cfset v10 = REFindNoCase("[^[:alnum:]]",firstLabelChar,1,false)>
    <cfif (#Len(label)# GT 63) OR (#v10# NEQ 0)>
    <cfset emailCheck.message = "Invalid e-mail address.">
    <cfreturn emailCheck>
    </cfif>
    </cfloop>
    <!--- E-mail address has passed the basic tests --->
    <cfset emailCheck.status = true>
    <cfset emailCheck.message = "">
    <cfreturn emailCheck>
    </cffunction>
    </cfcomponent>

    BKBK Guest

  13. #13

    Default Re: CFTRY inside a CFOUTPUT loop

    Boys,

    Let's be nice to each other. The point of the forum is for us to help each
    other not get into personal attacks and ing contests. I'm grateful for all
    constructive suggestions. I don't use Javax either but I'm willing to learn or
    use it if it works and it solves my problem.

    Mike

    MikeTennor Guest

  14. #14

    Default Re: CFTRY inside a CFOUTPUT loop

    >... Let's be nice to each other. The point of the forum is for us to help 
    T'was just a lighthearted riposte to what I assume was also a
    lighthearted remark. Happens even in the best of families.

    BKBK Guest

  15. #15

    Default Re: CFTRY inside a CFOUTPUT loop

    CFC addendum: <cfif Len(variables.email) LT 6 OR Len(variables.email) GT 250>
    BKBK Guest

  16. #16

    Default Re: CFTRY inside a CFOUTPUT loop

    http://www.macromedia.com/cfusion/exchange/index.cfm?view=sn130#view=sn131&viewN
    ame=ColdFusion%20Extension&loc=en_us&authorid=3310 0025&page=0&scrollPos=0&subcat
    id=0&snid=sn131&itemnumber=18&extid=1025226&catid= 0 a decent custom tag to
    validate email addresses, the comments are especially good to understand what
    it takes for an email address to validate according to the RFC.


    PaulH Guest

  17. #17

    Default Re: CFTRY inside a CFOUTPUT loop

    >... here's a decent custom tag to validate email addresses, the comments are
    especially 
    according to the RFC.
    Thanks for the info. Never heard of the RFC(Request for Comments?)
    Specification until
    now. I wrote the CFC just off the top of my head, in answer to the question in
    the forum.
    Never had to personally validate for e-mail, as ours is done courtesy of
    Hexillion,
    a commercial product.

    BKBK Guest

  18. #18

    Default Re: CFTRY inside a CFOUTPUT loop

    If you intend to use the
    http://www.macromedia.com/cfusion/exchange/index.cfm?view=sn131&extID=1025226#lo
    c=en_us&view=sn131&extID=1025226&viewName=ColdFusi on%20Extension&avm=1 in a
    production environment, then be aware of one security issue. It is not wise to
    display to the user, error messages like "Local part exceeds 64 character
    limit", "Domain part is not a valid IP address" and
    "Domain part is not a valid fully qualified domain name".

    We should never display the cause of CF or validation errors to the user. A
    malicious user
    might use the information to compromise our website.

    If Len(email) is zero, it's OK to ask user to give an e-mail address. In every
    other case
    where there's an error, I would simply tell user "Invalid e-mail address".


    BKBK Guest

  19. #19

    Default Re: CFTRY inside a CFOUTPUT loop

    Edit: Deleted irrelevant comment.
    BKBK Guest

Similar Threads

  1. trouble with loop inside output query
    By Yannovich in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: August 21st, 08:04 PM
  2. Adding inside of a loop
    By koeniga in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: April 15th, 03:09 PM
  3. concat cfloop index to cfoutput variable inside loop?
    By Damnit Spock! in forum Macromedia ColdFusion
    Replies: 0
    Last Post: April 8th, 09:03 PM
  4. populating anonymous arrays inside for loop?
    By Jeff 'japhy' Pinyan in forum PERL Miscellaneous
    Replies: 7
    Last Post: August 24th, 08:48 PM
  5. Help with loop inside loop and mysql queries
    By Petre Agenbag in forum PHP Development
    Replies: 1
    Last Post: July 16th, 07:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •