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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFMAIL from a nested output 1

Status
Not open for further replies.

sliver

Programmer
Nov 16, 2000
23
US
The following code will output a page with the desired information in the desired format but I can not figure out how to turn it into an email.

<CFQUERY datasource = &quot;datasource&quot;
Name = &quot;sched&quot;>
select * from table m
where EXISTS
(Select summary
FROM bills
WHERE type = m.Measure_Prefix
AND bill = m.Measure_Number + 70000)
order by Meeting_Date, Commit_Type, Commit_Name_Uppercase
</CFQUERY>

<CFSET type1 = &quot;Meeting&quot;>
<CFSET com1 = &quot;HOUSE&quot;>
<CFOUTPUT query = &quot;sched&quot;
group = &quot;Meeting_Date&quot;>
#DATEFORMAT(Meeting_Date)#</B><hr>
<CFOUTPUT>
#com1# #Commit_name_uppercase#<BR>
#timeformat(sched.Meeting_Time)# #sched.Meeting_Location#<BR>
#sched.Measure_Prefix# #sched.Measure_Number# Agenda item #sched.Agenda_Item_No#<BR>
#Type1#<BR><BR>
</cfoutput>
</cfoutput>

I have tried <cfmail> to my hearts content and surched through at least 4 reference manuals any help would be very helpfull.


 
The <cfmail> tag is pretty straightforward so if you're not getting a specific error message, I would check for problems in the message delivery. If there is not a SMTP server specified in the CF administrator, cfmail will make the e-mails but they won't get delivered. If the SMTP server is specified but is down or CF can't connect to it because of firewall issues or other, the messages will get dumped into the undeliverable folder and you'll never know. It's also possible that cf is delivering them to the SMTP server but the SMTP server is rejecting them due to relaying restrictions. These are put in place to keep an SMTP server from being used by spammers.

The cfmail tag is designed to use internet addresses so make sure you format your &quot;to&quot; and &quot;from&quot; fields as internet addresses like &quot;john@yahoo.com&quot; and not like corp. mail addresses as in &quot;John Smith&quot;.
 
Thanx but thats not it I went and configured the administrator first thing. one of the errors I have gotten is

A query driven CFOUTPUT tag is nested inside a CFMAIL tag that also has a QUERY= attribute. This is not allowed. Nesting these tags implies that you want to use grouped processing. However, only the top-level tag can specify the query that drives the processing.

that one is if I put the mail tag after the query and before any of the outputs. I can get it to either give me one email with each item put under a date on its own or a different email for each date but I cant get it to group the emal by the dates. of course I can get it to display a page groupped the way I want.
 
Ok, I now see what your problem is. I don't know of any way to do the grouping in cfmail but I think you can work around it. If I understand the way you want the grouping, you want one e-mail to go out for each date but contain basically all the items in the inner output grouping. If this is what you're trying to do, let me know as I helped a friend with this once but I can't remember the syntax that we ended up with. I'll ask him and find out how we eventually structured it. I believe it had to do with using cfloops instead of cfoutput inside the e-mail.
 
almost, at present it will give me one email for each date if I include the query in the mail tag which is much better than one email for each Item. Ispamed myself the first time I tried this than changed to DB so I had something workable. but I want one email with all the info grouped by date.

date
Item
Item

date
item

and so on..
 
My friend got back to me but he can't find the code we used before. The easiest solution if you want one e-mail is just to do a cfoutput loop and build up the message first and then do a single cfmail and send the dynamicly generated message. It's not elegant but should work.

Here's how I would re-structure your code to do this.

<cfset emailString=&quot;&quot;>

<CFOUTPUT query = &quot;sched&quot; group = &quot;Meeting_Date&quot;>

<cfset emailString=&quot;#emailString##DATEFORMAT(Meeting_Date)#</B><hr>&quot;>

<CFOUTPUT>

<cfset emailString=&quot;#emailString# #com1# #Commit_name_uppercase#<BR>
#timeformat(sched.Meeting_Time)# #sched.Meeting_Location#<BR>
#sched.Measure_Prefix# #sched.Measure_Number# Agenda item
#sched.Agenda_Item_No#<BR>
#Type1#<BR><BR>

&quot;>
</cfoutput>
</cfoutput>

<cfmail ....>
#emailString#
</cfmail>

I think that will work. It's not the optimal way but should get you around cfmail's shortcoming. If you want line breaks inside the message, you can insert #chr(13)##chr(10)# which will cause a line break in the e-mail message.
 
Thank you GunJack! that worked well. there may be a better answer but what you gave me works. once again I thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top