Skip to main content
nikos101
Inspiring
September 8, 2009
Answered

The emails get sent but the to address should list in the email

  • September 8, 2009
  • 1 reply
  • 2274 views

If I do something like this

<cfmail type="html" query="q" to="#q.email#

The emails get sent but the to address should list in the email, but they don't get listed.

This topic has been closed for replies.
Correct answer BKBK

The emails all go out but I thought I would have seen all the email recipients in the email header, thats all.

recip1@my.com,recip2@my.com,recip3@my.com,recip4@my.com

Looks like I'll have to create this string manualy


You should indeed create the string manually. There is really nothing wrong with your code. It is a peculiarity of Coldfusion that q.email behaves at once like a simple value and like a complex value.

Suppose there are 10 email addresses in the result set. Then <cfoutput>#q.email#</cfoutput> will display just the first one. However, <cfoutput query="q">#q.email[currentrow]# </cfoutput> will display all ten.

One way to create the string manually:

<cfsavecontent variable="emails_from_db"><cfoutput query="q">#q.email[currentrow]#,</cfoutput></cfsavecontent>

I have ignored the trailing comma at the end because I see you intend to stick an extra email at the end anyway.

1 reply

September 8, 2009

We need to see the rest of the code. Show the complete CFMAIL tag you are using.

nikos101
nikos101Author
Inspiring
September 8, 2009

  sure

  <cfmail type="html" query="q" to="#q.email# ,test@34.34" 
                from="noreply@my.com" subject="Notice"
            server="#Application.MailServer#" port="25" timeout="120">
           
          <cfmailpart type="text/html">
                                 <style type="text/css">
                                    p,h1,h2,h3{
                                    font-family:Verdana, Arial, Helvetica, sans-serif;
                                   
                                    }
                                   
                                    h1,h2,h3{
                                   
                                    font-size:14px;
                                    }
                                   
                                    p{
                                   
                                    font-size:12px;
                                    }
                                   
                                    </style>
                                
                            #body#
                           
                           
                            </cfmailpart>
                            <cfmailpart type="text/plain">
                           
                            #body#                           
                            </cfmailpart>

           
        </cfmail>

Inspiring
September 8, 2009

It's not clear what you are attempting.  Your existing cfmail tag calls for one email to be sent to each person in your query results.  That means if your query returns 20 rows, you send 20 separate emails.

Were you looking to send just one email to 20 people at once?