我有一個查詢返回多個結果,只有一列中的數據與特定報表編號不同。我想將結果分組爲一個報告編號,並將電子郵件發送給所有行動項目的一個人。下面是我的查詢cfmail組屬性拋出錯誤
<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 [email protected] Action 1 00:00.0 Repair NULL
4 13-0004 3 Robert Michael [email protected] fghfgh 00:00.0 Repair NULL
5 13-0005 4 Masoud Aghel [email protected] sdfsdfsdf 00:00.0 Repair NULL
5 13-0005 4 Masoud Aghel [email protected] hhjghj 00:00.0 Repair NULL
我想要做的就是發送一個電子郵件給多行具有相同調查的id action_who_email值。如果我使用CFOUTPUT組認爲這是輸出:
[email protected]
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:
[email protected]
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:
[email protected]
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="[email protected]" 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標籤被註釋掉,它們不會拋出連接異常。 我很抱歉,如果我的問題是非常通用的,但我要麼與Coldfusion做到這一點,或者我可能不得不寫一個函數來將我的結果集作爲臨時表。我相信,如果我知道如何使這項工作成功,那麼使用coldfusion更容易。
您能否更新您的問題並量化您的意思是「無效」? – 2013-05-10 10:24:32
這個錯誤表明在主機或端口上沒有運行郵件服務器? – 2013-05-10 10:57:24
是的,沒有郵件服務器,但我有其他類似於和來自地址的cfmail標籤,他們只是在coldfusion中去找不到的forlder。我沒有得到這個特定的錯誤。它只是當我在查詢中添加了這個特定的cfmail時,我遇到了這個錯誤。 – amsko 2013-05-10 11:00:05