Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP W/ QUERY!

Status
Not open for further replies.

NEL3644

Technical User
Sep 4, 2000
26
0
0
US
I created this code to notify users 1 week prior to expiration date...The query goes to the "Dates" TABLE and get the dates (field name: StartDate) and also goes to the "Program" TABLE to get the e-mail list (field name: EMail) of everybody whose dates are 1week prior to expiration date.
The problem I'm having w/ this code is that it gives me &quot;Error resolving parameter PROGRAM.EMAIL&quot; which is located in the &quot;TO:&quot; section of the <CFMAIL> tag. Will someone help me, please?


<cfset ExpirationDate = now() + 7>
<cfset ExpirationNum = DateFormat(#ExpirationDate#, &quot;yyyymmdd&quot;)>
<CFQUERY NAME=&quot;ExpirationNotice&quot; DATASOURCE=&quot;#Application.DataSource#&quot; DBTYPE=&quot;ODBC&quot;>
SELECT Dates.StartDate, Program.EMail
FROM Dates INNER JOIN Program ON Dates.ProgramID = Program.ProgramID
WHERE StartDate = #ExpirationNum# Order by StartDate
</CFQUERY>

<CFMAIL TO=&quot;#Program.EMail#&quot;
FROM=&quot;jukebox@maingo.com&quot;
SUBJECT=&quot;TEST&quot;
QUERY=&quot;ExpirationNotice&quot;>

This message is a TEST and was sent by an
automatic mailer built with CFMAIL...Please,
Disregard this e-mail...


</CFMAIL>
 
The parameter Program.email is used only in the query and not outside of the CFQUERY tags. To refer to a parameter being extracted by a query you must use CFQUERYNAME.PARAMETER

below I've changed the code you've submitted, assigning the values extracted from the query to variables within the query and in the CFMAIL tag refered to that variable in the form noted above (CFQUERYNAME.PARAMETER).

let me know if this helps

-Chris

<CFQUERY NAME=&quot;ExpirationNotice&quot;
DATASOURCE=&quot;#Application.DataSource#&quot;
DBTYPE=&quot;ODBC&quot;>

SELECT Dates.StartDate StartDate, Program.EMail EMail
FROM Dates INNER JOIN Program ON Dates.ProgramID = Program.ProgramID
WHERE StartDate = #ExpirationNum# Order by StartDate
</CFQUERY>

<CFMAIL TO=&quot;#ExpirationNotice.EMail#&quot;
FROM=&quot;jukebox@maingo.com&quot;
SUBJECT=&quot;TEST&quot;
QUERY=&quot;ExpirationNotice&quot;>

This message is a TEST and was sent by an
automatic mailer built with CFMAIL...Please,
Disregard this e-mail...


</CFMAIL>
 
Yep, it helps Chris!
The next error message I get is:
&quot;unknown exception condition TagCFMail::sendMessage&quot;---and it indicates that this error comes from the position where the &quot;TO=&quot; is located...

Do you have any idea why might cause this error?

Do I have to do anything else so that CFMAIL goes to the database, and grabs each record (each e-mail address) from the EMail field and automatically sends the same body message to everyone on this address list? If yes, please help me out w/ this one!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top