Populating a query inside of cfmail

Posted on 2006-05-28
Last Modified: 2013-12-24
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.

Question by:cmistre
    LVL 7

    Accepted 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#

    Author Comment

    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.


    Author Comment

    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

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now