For CFMail - I am building a To: list and BCC: list using cfset tolist and cfset bcclist
These output just fine. But when I add them into the cfmail - the tolist and bcclist error.
I am not sure why, as they are just comma delimited lists.
Get: The value of the attribute to, which is currently [email protected],[email protected],[email protected] is invalid.
When I hard code in the above list - it works just fine.
The alist and clists below create just fine, and look just fine to me. I can't seem to find a solution to what I'm doing wrong.
<cfoutput>
<cfif isdefined("form.checkbox1")><cfset clist = "#checkbox1#"></cfif>
<br><br>Check List #clist#
</cfoutput>
To:
<cfset tolist = "#clist#,<cfif alist is not "">#alist#,</cfif><cfif len(other)>#other#</cfif>">
<cfoutput>#tolist#</cfoutput>
BCC List - basically the same
<cfoutput>
<cfmail type="html" from="[email protected]" to="#tolist#" bcc="#bcclist#" mimeattach="#pdfpath#file.pdf" subject="File.pdf">
Blahhh
</cfmail>
</cfoutput>
I would suggest re-writing your code to scope your variables and also to remove the if statements from inside the cfset statements. Also, I'm assuming this isn't all of your code since tolist and bcclist are never set anywhere. Try the code below.