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

Looping

LEGEND ,
Oct 05, 2006 Oct 05, 2006

Copy link to clipboard

Copied

I am having a problem with looping over a query.
I have a query that contains all the people who have not opted out of a
list. I want to send them an email. I am using the query to specifiy the
loop, but I keep getting all the emails sent to the top address. I need it
to step and repeat through each person. What am I doing wrong?

<cfloop query="mailist">
<cfmail from="#campaign.emailfrom#" to="#mailist.email#"
replyto="#campaign.emailreply#" server="***" subject="#campaign.subject#">
<cfmailpart type="html">
<cfoutput>#campaign.html#</cfoutput>
</cfmailpart>
<cfmailpart type="text">
<cfoutput>#campaign.plaintext#</cfoutput>
</cfmailpart>
</cfmail>
</cfloop>


TOPICS
Advanced techniques

Views

423

Translate

Translate

Report

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 ,
Oct 05, 2006 Oct 05, 2006

Copy link to clipboard

Copied

Well that didn't seem to work too well. Each person on the list got 2 emails
and the message was supposed to be 'hello' but was:

'hello' on the first email and
'hellohellohellohellohello' on the second second..

There was a total of 4 people on the list...

Help!

cfif IsDefined ('Send_Mail')>
<cfmail from="#campaign.emailfrom#" to="#mailist.email#"
replyto="#campaign.emailreply#" server="***" subject="#campaign.subject#"
query="mailist">
<cfmailpart type="html">
<cfoutput>#campaign.html#</cfoutput>
</cfmailpart>
<cfmailpart type="text">
<cfoutput>#campaign.plaintext#</cfoutput>
</cfmailpart>
</cfmail>
<cflocation url="done.cfm" addtoken="no">
</cfif>



Votes

Translate

Translate

Report

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 ,
Oct 05, 2006 Oct 05, 2006

Copy link to clipboard

Copied

Instead of cfloop, try using the query attribute of cfmail.

Votes

Translate

Translate

Report

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 ,
Oct 05, 2006 Oct 05, 2006

Copy link to clipboard

Copied

Funny, that is the opposite of what adam told me. Atleast with that I was
only getting one 'hello' in my body a bunch of the emails.

When I tried to dump the variable that is being sent, I get two of them

<cfloop query="mailist">
<cfdump var="#mailist.email#">
</cfloop>


Votes

Translate

Translate

Report

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 ,
Oct 05, 2006 Oct 05, 2006

Copy link to clipboard

Copied

Nevermind. The email loop wasnt the problem. The inserting loop for the
query insert is.


Votes

Translate

Translate

Report

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 ,
Oct 05, 2006 Oct 05, 2006

Copy link to clipboard

Copied

LATEST
What happens when you do this:
<cfdump var = "#mailist#">

Votes

Translate

Translate

Report

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
Documentation