Skip to main content
Participant
June 11, 2009
Question

CFSCHEDULE AND CFMAIL

  • June 11, 2009
  • 1 reply
  • 1364 views

Hello,

I am trying to use cfschedule  with CFMail to send out a list of Work Orders due for the coming day.

I have it all working except when I try to query the db to get the list of work orders it seems to fail.  When testing

I comment out the query and it works, however when I invoke the query it does not work.

Code:

<cfset StartTime = #DateAdd('n',1,Now())#>
<cfset StartTime = #TimeFormat(StartTime,'HH:MM:SS')#>
<cfset startdate  ="#DateFormat(Now(),'MM/DD/YYYY')#">
<cfschedule action="Update"
             task="testone"
             operation="HTTPRequest"
             url="http://www.mesllc.net/ems/cmms/admin/account/act_dailywo.cfm"
             startdate="#startdate#"
             starttime="#starttime#"
             interval="ONCE"
             resolveurl="Yes"
             publish="No">

act_dailywo.cfm

<cfquery NAME = "gwo" DATASOURCE="#ODBC_DataSource#">
   SELECT * from tblParkProfile;
</cfquery>

  <CFMAIL FROM="mbloise@mesllc.net"
        to="mikebloise@yahoo.com"
        Subject = "Schedule with query"
        server = "localhost">
        Message:    
</cfmail>

When I comment out the query it sends the email, however when I remove the comments it does not work.

Please note I changed the WO query to a simple select query.  The query is correct.

I am using Coldfusion MX7 on a shared server.

Thanks for the help.

Mike

    This topic has been closed for replies.

    1 reply

    tclaremont
    Inspiring
    June 12, 2009

    Place the query on it's own dedicated page for testing.

    Put #DWO.RecordCount# after the query.

    Run the page.

    Do you get the results you expect?

    mbloiseAuthor
    Participant
    June 12, 2009

    Thanks for the relpy.  I am still having issues.  It seems that when I reference the query it does not work:

    qry_wo.cfm

    <cfquery name = 'gwo' datasource="#ODBC_DataSource#">
    Select * from tblParkProfile;
    </cfquery>

    *************************************************************************

    <cfset

    StartTime = #DateAdd('n',1,Now())#>
    <cfset StartTime = #TimeFormat(StartTime,'HH:MM:SS')#>
    <cfset startdate ="#DateFormat(Now(),'MM/DD/YYYY')#">
    <cfinclude template = 'qry_wo.cfm'>
    <cfoutput>#gwo.recordcount#</cfoutput>

    <cfschedule action="Update"
    task="testone"
    operation="HTTPRequest"
    url="http://www.mesllc.net/ems/cmms/admin/account/act_dailywo.cfm"
    startdate="#startdate#"
    starttime="#starttime#"
    interval="ONCE"
    resolveurl="No"
    publish="No"

    >

    act_dailywo.cfm

    <CFMAIL FROM="mbloise@mesllc.net"
    to="mikebloise@yahoo.com"
    Subject = "Schedule with queryxxx"
    server = "localhost">
    Message:
    </cfmail>


    mbloiseAuthor
    Participant
    June 12, 2009

    Sorry posted too soon.

    Anyway;  I isolated the query to another file.  The query works fine, recordcount of 300. 

    Within the CFMAIL body,  if I do not reference the query (#gwo.recordcount#) everything works find.  However, if i do put this into the body, it fails.

    Also, if I bypass the schedule and just call the CFMAIL code with #gwo.recordcount# it works.

    Thanks,

    Mike