我有一个CF计划任务,通过电子邮件发送管理员用户的电话摘要。我想添加为某些管理员用户通过电子邮件发送报告的功能。附加报告是每个管理员用户动态的,并存储在表中。我不能只是报告代码,因为它可能会改变或不存在给下一个用户。也许我应该使用CFHTTP,但我并不熟悉它。
<cfloop query="qGetTelemateEmails">
<cfif trim(QGetTime.Call_Email_On_Hour) eq "" or listfind(#QGetTime.Call_Email_On_Hour#,datepart("h",now()))>
<cfset TotalTime = 0>
<cfset NumberOfCalls = 0>
<cfmail ........></cfmail>
以下代码也是我要通过电子邮件发送报告的地方。
<cfquery name="QAdditionalReports" datasource="#request.dtsrc#">
Select *
From Admin_Telemate_Additional_Query_Daily as a LEFT OUTER JOIN
Admin_Users AS C ON A.AdminID = C.adminID LEFT OUTER JOIN
Admin_Telemate_Available_Queries AS b ON A.description = b.description
where a.adminid = #val(QGetTime.call_admin_user_id)#
</cfquery>
<cfif QAdditionalReports.recordcount gt 0>
SEE CODE BELOW -------------------------------------------------------------
</cfif>
</cfif>
</cfloop>
这是我想要“包含/执行”的报告代码。我从查询表条目中获取代码的URL。
<cfquery name="QGetCommEct" datasource="#request.dsn#">
select *
from Q_ES_Communications_by_Search_Number
where upper(communication_type) = 'T'
and Date_Entered = '#dateformat(now(),"yyyy/mm/dd")#'
and consultant_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.adminid#">
order by date_Entered
</cfquery>
<cfmail>
<div style="text-align:center; font-weight:bold; ">Communications Files Query</div>
<table>
<tr>
<td>
<table style="font:Arial, Helvetica, sans-serif x-small; border:1px solid black; ">
<tr>
<td><strong>Type</strong></td>
<td><strong>Cons</strong></td>
<td><strong>Last Name</strong></td>
</tr>
<cfoutput query="QGetCommEct">
<tr valign="top">
<td>#QGetCommEct.Communication_Type#-#QGetCommEct.Category#</td>
<td>#QGetCommEct.AS400_Initials#</td>
<td>#QGetCommEct.lastname#</td>
</tr>
</cfoutput>
</table>
</td>
</tr>
</table>
</cfmail>
我用
替换了cfif QAdditionalReports.recordcount gt 0<cfloop query="QAdditionalReports">
<cfhttp url="#QAdditionalReports.QueryURL##QAdditionalReports.QueryName#?adminid=#val(QGetTime.call_admin_user_id)#&emailto=#qGetTelemateEmails.Telemate_Email#">
<cfmail to="vj@gmail.com" from="server@tt.com" subject="Recap of daily phone calls" type="html" spoolenable="false"><cfdump var="#cfhttp#"></cfmail>
</cfloop>
电子邮件包含;
struct
Charset [empty string]
ErrorDetail [empty string]
Filecontent [empty string]
Header HTTP/1.1 503 Server Error Content-Type: text/html Date: Wed, 13 Feb 2013 15:11:17 GMT Server: Microsoft-IIS/7.0
Mimetype text/html
Responseheader struct
Content-Type text/html
Date Wed, 13 Feb 2013 15:11:17 GMT
Explanation Server Error
Http_Version HTTP/1.1
Server Microsoft-IIS/7.0
Status_Code 503
Statuscode 503 Server Error
Text YES
可能是我需要做一个HTTPS
答案 0 :(得分:0)
您可以将您尝试重复使用的代码和“远程调用”放在cfc中,或者将其包含在cfinclude中。
编写CFC将是更好的方法。 Here is some documentation.
<cfcomponent ...>
<cffunction name = "additionalReports" ...>
<cfargument name = "adminid" ...>
<cfargument name = "emailto" ...>
<!--- dynamic query using your adminid here ---->
<cfmail to = "#arguments.emailTo#" ...>
<!--- nicely formated output --->
</cfmail>
</cffunction>
<cfcomponent>
您可以在计划任务中调用cfc,如下所示
<!--- make the object. assume the cfc is in the same folder named adminreports.cfc --->
<cfset reportObject = createObject("component", "adminReports")>
<cfset reportObject.additionalReports(val(QGetTime.call_admin_user_id), qGetTelemateEmails.Telemate_Email)>