8 Replies Latest reply on Nov 24, 2007 3:35 PM by cf_dev2

    cfbreak?

    craig_mac Level 1
      Hi i have a cfloop inside a scheduled task, which loops though cfpop emails

      i get information from the body of the email (which all email i recive have the same format),

      cfloop query="popemails"
      cfif message id (which is in the body of the email) matches a record in my table
      then delete the email
      else
      process the email with code

      this i what i am trying to do, but for some reason some times if there is a match in the table the email is still processed causing duplication.

      do i need to use cfbreak after i delete the email, would this start the loop again? as it is inside a scheduled task?
        • 1. cfbreak?
          jdeline Level 1
          How are you extracting the message id from the e-mail? Do you use the Trim( ) function to remove any possible leading or trailing spaces? CFBREAK will take you out of the loop.
          • 2. cfbreak?
            craig_mac Level 1
            HI i dont need to use trim as the message id is generated by a windows application,no spaces are every present!!

            so when i check the log i can see some duplicates of the messageid are the same right after each other,
            if i use cfbreak and it takes me out of the loop, would the loop start over again or would the schedule task have to run again?

            instead of cfbreak is there a way to delete the email then restart the scheduled task page?
            • 3. Re: cfbreak?
              jdeline Level 1
              Does the following represent your process flow?

              • 4. Re: cfbreak?
                craig_mac Level 1
                ok many thanks

                when you say "if you know how many Windows emaliIds you have"

                each email i receive has a different unique windows email id and there is only one per email..

                i think my current code maybe processing the email twice in some cases, thats why i am putting this check in place!!

                so which would be the best option for me to use?
                • 5. Re: cfbreak?
                  jdeline Level 1
                  Probably the second one.
                  • 6. cfbreak?
                    craig_mac Level 1
                    ok thanks

                    i am just worried why i am getting duplicates from my current code which i have attached below, is it possible that when i do the query GetMessage that if a messageID is inserted in the previous loop is not yet in there?

                    does my code look ok?

                    • 7. cfbreak?
                      jdeline Level 1
                      Something to look at - when you delete an e-mail, your ACTION and MESSAGENUMBER attributes do not have a space between them: ACTION="Delete"MESSAGENUMBER="1">

                      Do a CFDUMP after your first CFPOP, and a CFOUTPUT after your getMessage CFQUERY. This debug results should show you what's going on. See code below.

                      • 8. Re: cfbreak?
                        cf_dev2 Level 1
                        > <cfset str_idd = trim(listlast(listgetat(mymessage, 7, "|"), "~"))>
                        > WHERE MainAppMessageID = '#str_idd#'

                        Isn't the message number already a column in the POP query : queryname.messagenumber