• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Help with CFMAIL sending just one record from the query.

I am using CFMAIL to send a report automatically.  In my testing I have set up two records in the table that the mail query looks at to populate the body of the email.

Problem is that the email contains just one of the records.
How do I change my code to send an individual all the records associated to that person?

Here is my simple code:

<cfloop query="get_mail">
  <cfmail to="#email#" cc="#pmemail#" from="me@me.com" subject="Overdue Assessment" type="HTML">

<!--  body of the email here -->

</cfmail>
</cfloop>
0
g118481
Asked:
g118481
1 Solution
 
TallerMikeCommented:
<cfoutput query="get_mail" group="email">
 <cfmail to="#email#" cc="#pmemail#" from="me@me.com" subject="Overdue Assessment" type="HTML">

  <cfoutput>List the overdue Assessment here...</cfoutput>
<!--  body of the email here -->

</cfmail>
</cfoutput>

Use the GROUP attribute to spit out one email per email address. Then do an inner CFOUTPUT loop to loop through the assessments that are overdue.
0
 
Noodles22Commented:
<cfmail query="get_mail"to="#email#" cc="#pmemail#" from="me@me.com" subject="Overdue Assessment" type="HTML">
<!--  body of the email here -->
</cfmail>

Your cfloop code should work the same as above, but you might want to check that your query is returning more than one record

<cfdump var="#getmail#">
0
 
WasistdasCommented:
<cfloop query="get_mail">
 <cfmail to="#email#" cc="#pmemail#" from="me@me.com" subject="Overdue Assessment" type="HTML">

Dear #person#,

Here are your records associated with you:

<cfquery name="your_records">
select * from records
where person='#person#'
</cfquery>
#your_records.records#<br>

</cfmail>
</cfloop>
0
 
anandkpCommented:
what u cdl also do is

<CFSET x = "">

<cfquery NAME="get_mail">
    select ......
</CFQUERY>

<cfloop query="get_mail">
    <CFSET x = "#table_FieldName#"><!--- u can use multiple text along with htmls for formatting as well - put everything in "x" for all the records the user has --->    
</CFLOOP>

then send him one mail with all records - instead of multiple emails of all records !

<cfif x NEQ "">
    <cfmail to="#email#" cc="#pmemail#" from="me@me.com" subject="Overdue Assessment" type="HTML">
    Dear #name_of_person#
   
        #x#
   
    thanx
    #admin_Name#
    </cfmail>
</CFIF>

let me know

K'Rgds
Anand
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now