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

Populating a query inside of cfmail

Can anyone tell me how I would be able to do a query INSIDE cfmail?

I have a particular area of the mail that would populate differently for the recipient.

And it seems that by default, cfmail acts as though it starts with <cfoutput>

My problem is that, if I want ALL the records from a particular query on the page to loop through, I am getting a "nesting" area since that <cfoutput query> is withing <cfmail>

Is there a way I can do a typical <cfoutput query> inside cfmail?

Please help, I hope this is not impossible.

  • 2
1 Solution
I'm probably missing something here but, why not do this:

<cfquery name="getdata" datasource="foo">
<cfloop query="getdata">
  <cfquery name="getdata2">
    SELECT more stuff
  <cfoutput query="getdata2">
    <cfmail blah blah>
      #variable# blah blah #another variable#
cmistreAuthor Commented:
I found the answer in here already, and I appreciate this reply...

Just so you know, the problem with whats above is that inside cfmail, you can not use <cfoutput> or <cfoutput query="whatever"> anywhere.

Inside CFMAIL command you just do <cfloop query> instead for the same results as a <cfoutput query> outside of cfmail.

cmistreAuthor Commented:
and also the <cfoutput> on the outside of cfmail is unnecessary since it automatically assumes its <cfoutput> and it would loop the whole email entirely and not just a specific query inside the one email...

Thanks just in case anyone else gets stuck with the same problem

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

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