因此,我正在将旧版应用程序转换为ColdBox MVC,并尝试将标签转换为脚本。过去我会做的
<cfmail
query="getRecipients"
type="text/html"
from="Me <me@me.org>"
to="#getRecipients.email#"
subject="Hello everybody from me">
<p>Hey #getRecipients.name#, how are you?</p>
</cfmail>
我完成了。邮件将被发送到从getRecipients查询返回的任何人。但是现在看来我必须
var oMail = mailService
.newMail(
to="test1@test.com",
from="me@me.org",
subject="Hello everybody from me",
bodyTokens={ name=name}
);
oMail.setBody("
Hey @name@, how are you?
");
var results = mailService.send( oMail );
}
发送给单个收件人或以逗号分隔的列表时,它本身似乎过于罗word,但至少可以起作用。但是,无论我做什么,我都无法将其发送到查询的收件人列表中。
我尝试to = getRecipients并得到一个错误,指出“ to”的值不是字符串。我尝试to =“ getRecipients”,虽然我没有收到错误消息,但是没有发送邮件(甚至排队等待发送)。其他各种尝试也都出错或无提示失败。
我阅读了SO discussion here,这似乎表明在基于脚本的邮件中使用查询实际上并不能完成。但是那个讨论是从2012年开始的-肯定不再是这种情况了,对吧?当然可以在脚本中复制这一非常基本的功能,对吗?我想念什么?我对此进行了大量研究,发现的每个示例仅将其发送到单个硬编码地址。
我将对此有任何建议。非常感谢您的帮助!
答案 0 :(得分:2)
我相信会是:
var oMail = mailService
.newMail(
to=valueList(getRecipients.email),
from="me@me.org",
subject="Hello everybody from me",
bodyTokens={ name=name}
);