我有一个查询返回多个结果,其中只有一列中的数据与特定报告编号不同。我想对一个报告编号的结果进行分组,并将所有操作项的电子邮件发送给一个人。以下是我的查询
<cfquery name="qryCorrectiveDueDate" datasource="#application.config.DSN#">
SELECT FR.report_id,
FR.report_number,
IR.investigation_id,
CA.action_who,
CA.action_who_email,
CA.action_what,
CA.action_when,
CA.action_type,
CA.action_complete_date
FROM xyz_gir.dbo.xyz_flash_report AS FR,
xyz_gir.dbo.xyz_investigation_report AS IR,
xyz_gir.dbo.xyz_corrective_actions AS CA
WHERE FR.report_id = IR.report_id
AND IR.investigation_id = CA.investigation_id
AND DATEDIFF(day,CA.action_when,GETDATE()) > 1
AND CA.action_complete_date IS NULL
ORDER BY IR.investigation_id
</cfquery>
结果集如下所示:
report_id report_number investigation_id action_who action_who_email action_what action_when action_type action_complete_date
2 13-0002 2 Hans-Joerg Wolf hans-joerg.wolf@xyz.com Action 1 00:00.0 Repair NULL
4 13-0004 3 Robert Michael robert.michael@xyz.com fghfgh 00:00.0 Repair NULL
5 13-0005 4 Masoud Aghel Masoud.Aghel@xyz.com sdfsdfsdf 00:00.0 Repair NULL
5 13-0005 4 Masoud Aghel Masoud.Aghel@xyz.com hhjghj 00:00.0 Repair NULL
我想要做的是向具有相同调查 ID 的多行的 action_who_email 值发送一封电子邮件。如果我使用 cfoutput 组属性,这是输出:
hans-joerg.wolf@xyz.com
Report ID: 2
Report Number: 13-0002
investigation id: 2
Action Who :Hans-Joerg Wolf
Action What: Action 1
Action When: 2013-04-26 00:00:00.0
Action type:Repair
Action Complete Date:
robert.michael@xyz.com
Report ID: 4
Report Number: 13-0004
investigation id: 3
Action Who :Robert Michael
Action What: fghfgh
Action When: 2013-05-05 00:00:00.0
Action type:Repair
Action Complete Date:
Masoud.Aghel@xyz.com
Report ID: 5
Report Number: 13-0005
investigation id: 4
Action Who :Masoud Aghel
Action What: sdfsdfsdf
Action When: 2013-04-29 00:00:00.0
Action type:Repair
Action Complete Date:
Report ID: 5
Report Number: 13-0005
investigation id: 4
Action Who :Masoud Aghel
Action What: hhjghj
Action When: 2013-04-29 00:00:00.0
Action type:Repair
Action Complete Date:
这是我的cfoutput:
<cfoutput query="qryCorrectiveDueDate" group="investigation_id">
<b>#action_who_email#</b><br>
<cfoutput>
Report ID: #report_id#</br>
Report Number: #report_number#</br>
investigation id: #investigation_id#</br>
Action Who :#action_who#</br>
Action What: #action_what#</br>
Action When: #action_when#</br>
Action type:#action_type#</br>
Action Complete Date: #action_complete_date#</br></br>
</cfoutput></br>
</cfoutput>
但是,如果我在查询中对 cfmail 执行相同的操作并将其分组,则会引发 javax.mail.MessagingException:无法连接到 SMTP 主机:127.0.0.1,端口:25;错误。
我的 CFMAIL 代码如下
<cfmail query="qryCorrectiveDueDate" from="EHS@jdsu.com" to="#action_who_email#" group="#investigation_id#" subject="xyz">
<p>#action_who#,</p>
<p>Due Dates for Corrective Actions for the Incident #report_number# have lapsed </p>
<p>You are receiving this notification, as the Manager/Supervisor to implement the Corrective Actions </p>
<p>Incident No: #report_number# </p>
<p>Corrective Action: #action_what#</p>
<p>Due Date: #action_when#</p>
</cfmail>
请注意,我在本地使用 xampp 运行 Coldfusion,虽然邮件没有送达,但我可以在 Coldfusion 的未送达文件夹中看到它们。如果此 cfmail 标记被注释掉,同一文件还有其他 cfmail 标记不会引发连接异常。如果我的问题非常笼统,我深表歉意,但我要么必须使用冷融合来做到这一点,要么我可能必须编写一个函数来将我的结果集视为临时表。如果我知道如何进行这项工作,我相信冷融合会更容易。