3 Replies Latest reply on Dec 19, 2006 5:40 AM by Dan Bracuk

    cfmail loop query

    Keith444
      can some one help me with this query please

      i have a cfmail running off a query


      i want to be able to send mail to a list of recipietns from my database

      the query below works but only sends emails to the first contact in the list

      what can i do to my query to change this?

      <CFQUERY datasource="#application.ds#" Name="GetSch">
      SELECT cc.Code, gg.PlayerPhone, dd.Message, cc.Club_Abbrev
      FROM appoint_table dd, SMS_Players_Table gg, SMS_Clubs_Table cc
      WHERE ServerSMS <= #CreateODBCDateTime(Now())# AND dd.App_ClientID = gg.PlayerID AND dd.LoginID = cc.ClubID
      AND ServerSMS <> ''
      </cfquery>

      <cfmail to = "craig_mac@bigutton.com.au" query="GetSch"
      from = "test"
      subject="">

      to:#Code##PlayerPhone#
      text:#Message#
      from:#Club_Abbrev#
      </cfmail>
        • 1. Re: cfmail loop query
          Dan Bracuk Level 5
          Your query does not look like it's selecting any email addresses.

          Your cfmail tag has a constant in the to attribute and will probably crash since the from attribute does not have a valid email address as it's value.
          • 2. Re: cfmail loop query
            Keith444 Level 1
            ok thank i just realised what i need

            just to go to one email as the cfmail is at the min

            but i need to loop through the mail output so it send 30 emails to the same email

            with the different
            to:#Code##PlayerPhone#
            text:#Message#
            from:#Club_Abbrev#

            for each record retreved form the query
            • 3. Re: cfmail loop query
              Dan Bracuk Level 5
              Do not use a query attribute in your cfmail tag. Put a cfloop in the part where you compose your mail body.

              Alternatively, use cfsavecontent to build your mail body and stick the resulting variable into the tag. That's the method I use.