9 Replies Latest reply on Dec 26, 2007 7:17 AM by JR "Bob" Dobbs-qSBHQ2

    "CFMail to" based on code matches

    newportri Level 1

      I have a form that an administrator fills out that has fields for up to 10 numeric inputs (code numbers).

      If one of the inputed values matches that value (code) contained in customer's record, an email gets generated to that customer.

      Each customer can have up to 10 codes - there is a field in each of their records for code 1, 2 etc. There is always at least one code, but that may be it.

      I'm doing:

      The form:

      <p>Code 01: <input type="text" name="code_01" size="6" maxlength="6"></p>
      <p>Code 02: <input type="text" name="code_02" size="6" maxlength="6"></p>


      The action:

      <cfquery name="emailData" datasource="customers">
      SELECT customer_ID, customer_email, vendor_cccode_01, vendor_cccode_02, vendor_cccode_03, vendor_cccode_04, vendor_cccode_05,
      vendor_cccode_06, vendor_cccode_07, vendor_cccode_08, vendor_cccode_09, vendor_cccode_10
      FROM main


      <cfloop query="emailData">

      <cfmail to="#emailData.customer_email#" etc.

      So if the customer only has one code, that's fine and it works.

      I have tried using

      WHERE form.code_01=vendor_cccode_01
      OR etc,do the mailing


      <cfif #form.code_02# IS NOT "">OR etc., do the mailing


      <cfif emailData.vendor_cccode_01 EQ "#form.code_01#" OR emailData.vendor_cccode_02 EQ "#form.code_02#">

      do the mailing

      Can't get anything to work.

      Any help would be appreciated