Helpful Information
 
 
Category: ColdFusion
Different automated emails send with same email information

Problem:
This file is for automated email reminders. The emails are called by "template." It loops through the active emails. For each email it pulls a different set of email addressed with "getAddress." Here is the part I haven't been able to figure out; On screen (see image below) it appears that the emails pulled the proper data, and email lists. The emails right now are all directed at me, and I even get the proper number, including the correct "to" email addresses, of emails BUT the emails all have the email info (from, subject, body) as the first email in the loop.

Below is the code (from, to, etc. are hard coded for the time being), and a screen shot of the results (browser side.)

Any suggestions would be greatly appreciated! Thanks!



<cfloop query="template">
<cfset getAddress=getNonActivatedGreenKeys(#template.accountList#, "", "", #template.issuedDays#)>
<cfif debugmode>
<cfmail
query="getAddress"
server="#BG_MAIL_SERVER#"
from="#template.from#"
to=""
bcc=""
replyto=""
subject="#template.subject#"
spoolEnable="yes">#getAddress.issuedToEmail# #template.body#</cfmail>
<cfelse>
<cfmail
query="getAddress"
server="#BG_MAIL_SERVER#"
from="#template.from#"
to=""
bcc=""
replyto=""
subject="#template.subject#"
spoolEnable="yes">#template.body#</cfmail>
</cfif><!--- closes debugmode if --->
<div style="background-color: #FFFFFF; border: 2px solid #000000; padding: 10px; margin-bottom:15px;">
<p>
<b>Email Sent to <cfoutput>#getAddress.recordCount#</cfoutput> Recipients</b><br />
<cfoutput>
Name: #template.name#<br />
From: #template.from#<br />
Subject: #template.subject#<br />
Body: #template.body#<br />
</cfoutput>
</p>
</div>
</cfloop><!--- closes template query --->


http://www.philipscheffer.com/orphans/images/emailresults.jpg

My boss was able to figure it out (yey bosses!) There is a bug in CF 7 that causes the inside loop (<cfmail query="">) to not update the next time through the outside loop. The outside loop worked fine, which is why on screen, it appeared fine.

To fix it I had to change #template.body# to #template.body[template.currentrow]# anywhere template was being used inside the cfmail tags, setting up an array to pull the correct data from the template loop.

Cheers!
Phil










privacy (GDPR)