kidaiu
kidaiu

Reputation: 101

CFMail sending to first recipient of query result only

When attempting to send an email to multiple recipients using ColdFusion, only the first row is receiving the email and it seems to be hit three times but only sending once. This works but all recipients are visible and the cfoutput is displayed as many times are there are recipients:

<cfmail
to = "#ValueList(getEmail.Schd_Email)#"
from="[email protected]"
subject="This is a Test"
type="HTML"
query="getEmail"
failto="[email protected]">
The location has been moved to <b><cfoutput>#location#</cfoutput></b><br/>
</cfmail>

This only sends to the first person listed in the query and the cfoutput in the body is still listed as many times as there are recipients.

<cfmail
to = "#Schd_Email#;"
from="[email protected]"
subject="This is a Test"
type="HTML"
query="getEmail"
failto="[email protected]">
The location has been moved to <b><cfoutput>#location#</cfoutput></b><br/>
</cfmail>

I can output the query to the page and see all emails listed. Not sure why the latter does not work. Any ideas?

Upvotes: 0

Views: 395

Answers (2)

Miguel-F
Miguel-F

Reputation: 13548

Since you are using the query attribute of the cfmail tag you do not need to use the ValueList() function. The query attribute handles that functionality for you. It also negates the need for using a delimeter between each of the "to" addressees. It should work like this assuming you have valid email addresses in your query results.

<cfmail
    to="#getEmail.Schd_Email#"
    from="[email protected]"
    subject="This is a Test"
    type="HTML"
    query="getEmail"
    failto="[email protected]">
    <div>The location has been moved to <b><cfoutput>#location#</cfoutput></b></div>
</cfmail>

Upvotes: 1

W Gunvant
W Gunvant

Reputation: 111

I think you should use ';' delimiter in valueList(). the default delimiter for valueList() is ','. If you pass delimiter ';' it might work. Try this one #ValueList(getEmail.Schd_Email,";")#

Upvotes: 2

Related Questions