Copy link to clipboard
Copied
I am trying to send an email with CFschedule... from what I can tell by looking at the documentation, I am doing it right. I am not getting any error messages but the email is not sending. The CFschedule is the action page of a form. When the form processed, it should set the CFschedule for another action page which sends the email. Here is the code -
The code that fires on a form submit (I have verified that this page is being called properly)
<cfschedule
action="update"
task ="sendemail"
startDate ="3/18/2014"
endDate ="3/18/2014"
operation = "HTTPRequest"
interval ="once"
url = "sendemail.cfm"
startTime = "10:43:00"
>
And the action page.
<cfmail
from="xxxxx@xxx.Xxx"
to="xxxxx@xxxx.xxx"
subject="Your Equipment Test">
Your equipment lease is due back to CIE tomorrow.
</cfmail>
Thanks!
It is for an inventory system. The form includes a return date for borrowing an item. When they submit the form, the cfschedule will use the return date from the form variable as the enddate attribute on the cfschedule. So...the day their equipment is due back, they recieve an email.
My code does not reflect this yet, I hardcoded a date for testing purposes.
And actually, I got it to work. I had to change the URL attribute to an absolute link instead of relative.
-sean
Copy link to clipboard
Copied
Couple questions here...
First.. Why are you using cfschedule to just send an email? This could be more easily done in the form processor.
Second... If you are using the cfschedule to do it what happens if 2 people submit the form at the same time?
As for the email, check in the undelivered folder on the server for the email. If it was unable to be sent it would be in there.
HTH,
--Dave
Copy link to clipboard
Copied
It is for an inventory system. The form includes a return date for borrowing an item. When they submit the form, the cfschedule will use the return date from the form variable as the enddate attribute on the cfschedule. So...the day their equipment is due back, they recieve an email.
My code does not reflect this yet, I hardcoded a date for testing purposes.
And actually, I got it to work. I had to change the URL attribute to an absolute link instead of relative.
-sean
Copy link to clipboard
Copied
By the way....see my other comment first. - is there a better way to do what I mentioned in my other comment?
Thanks
Copy link to clipboard
Copied
I wouldn't do it this way at all. What happens when you have 1000 items, or even 2, due in the future? You would have a scheduled task for each item. This would create a management nightmare that I wouldn't want to deal with.
I would just run a task each day to poll for items doe that day and then send an email. Much cleaner approach and far less prone to failure. You could easily write code to deail with issues, resend emails, and generally recover from failures with little effort.
HTH,
--Dave