Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Enthusiast ,
Sep 08, 2009 Sep 08, 2009

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.

TOPICS
Getting started
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 09, 2009 Sep 09, 2009

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 qu

...
Translate
Guest
Sep 08, 2009 Sep 08, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 08, 2009 Sep 08, 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 08, 2009 Sep 08, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 08, 2009 Sep 08, 2009

I get the impression that the intent is to loop through a query list of email addresses. This is OK in theory.

I am unclear as to what the failure mode is. Is the mail being sent ANYWHERE? Does ANYONE receive it? Does it get stuck in the spool folder?

For starters, I suggest you look at your to: attibute. What is this?  ,test@34.34. If it is a second email address that you want the mail sent to, use a semicolon and get rid of the space.

Better yet, try moving test@34.34 to the the BCC line in your email. Send the email again, and let us know what happens.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 09, 2009 Sep 09, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2009 Sep 09, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 09, 2009 Sep 09, 2009

I done it like this

    <cfset emailTo = ''>
         <cfloop query="q">
             <cfset emailTo = emailTo & q.email & ','>
         </cfloop>

easier?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2009 Sep 09, 2009
LATEST

I done it like this

    <cfset emailTo = ''>
         <cfloop query="q">
             <cfset emailTo = emailTo & q.email & ','>
         </cfloop>

easier?

Perhaps the most efficient way is Dan's,namely

emailTo=valueList(q.email)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 09, 2009 Sep 09, 2009

From a coding perspective, you don't have to do anything manually.  Take the query attribute out of the cfmail tag and use a valuelist for the to attribute.

From an email perspective, sending one email to a bunch of people may or may not be a good idea.  All it takes is one recipient to do a Reply All and lot's of people get start to get mail they don't know about.  Another alternative is to send it to the sender, and bcc the real recipients.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 09, 2009 Sep 09, 2009

Are you using the query loop specifically so that you send a separate email to each recipient in the query result? That would explain why you dont see everyone else's email address when the mail goes out. You are literally sending a separate email for each email address in your query result.

If that is your intention, that is OK, but from your post I get the impression that you want to send a single email with all recipients included.

To do that, you need to assemble a string consisting of each email address value in the query result. Call it EmailList or some such thing. Then remove the query attribute from around your cfmail tag, since you will not be looping through a query. Change your TO: field to #EmailList#.

As others have suggested, including everyone in the TO: field is considered discourteous. I support the idea of putting the recipients on the BCC line to respect other's privacy.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources