By: Rhino

<CFSET today = "#DateFormat(now(),'mm/dd/yyyy')#">

<cfquery name="change"
             datasource=
"[yourDSN]"
             dbtype=
"ODBC">

        SELECT  * 
        FROM     change
        WHERE   impdate is '#today#'

</cfquery>


<cfloop query="mailing">


   <CFMAIL
            to=
"whoever@youwant.com"
            from=
"valid@from-address.com"
            Subject=
"Important">

   Message here regarding today's important event.

   </CFMAIL>

</cfloop>


This code saved my butt on several occasions. I had a db with different events happening that were entered by several other people in different locations. Part of more code updated a calendar program, but this little bit sent an email directly to whoever (me) early in the morning of the event.

This code was triggered every day at 1am by CFschedule. All that does is hit the page and execute it, the code on the page did the rest. First thing I did was set today's date format in the same manner it was entered into the database. Then I queried the db for any row with the field "impdate" the same as today's date. If there are none, it simply does nothing. If there are any, it sends out a preformatted email, or even a db driven email that tells what the event is and when it will happen.

So each morning I knew what was going to happen as soon as I read email. You could even have it go to your mobile phone if you have email capabilities.

About This Tutorial
Author: Rhino
Skill Level: Beginner 
 
 
 
Platforms Tested: CF5
Total Views: 105,911
Submission Date: December 13, 2002
Last Update Date: June 05, 2009
All Tutorials By This Autor: 10
Discuss This Tutorial
  • I am trying to use a Newsletter like system to email guests about upcoming events, however i'd like to use an EventID passed on from a previous page. SELECT * FROM event_registry WHERE EventID = #URL.number# ORDER BY ID ASC #FORM.Message#

  • If I run a query to retrive user's email, name, username, password, etc. and insert those variables in the body of my email, will the loop tag allow me to repeat the process for every user who meets my criteria? Will the information from the database be sent only to the user for which the information is? thanks.

  • WHERE impdate is '#today#' Just be changing the date to whatever yous want.

  • how would i be able to get hold of records that are like 1 month or 12 months old.

Advertisement


Website Designed and Developed by Pablo Varando.