Solved

Known issues with CFmail and CFquery?

Posted on 2004-09-03
4
304 Views
Last Modified: 2013-12-24
I'm facing a problem with inserting into a db in a cftransaction and right after that sending an e-mail.
the cf transaction contains a number of queries, and last one is the insert query.
I tried both ways (since i would like to send the e-mail only when the data is successfully inserted) to put the cfmail inside the cftransaction tag, and outside it.

In any case, all the queries excute correctly except the insert query. If i remove the cfmail, the problem is still presisting. Only when i delete the query and rewrite it (of course no cfmail in this case) that it works!

Any ideas?
0
Comment
Question by:MMsabry
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:hart
ID: 11971210
one suggestion woul be to put all your queries in a stored procedure if possible...
and after the insert quert send a variable out from the stored proc that indicates wether to send the mail or not...

Regards
Hart
0
 
LVL 11

Accepted Solution

by:
hart earned 250 total points
ID: 11971216
also don't put the cfmail inside the cftransaction...
inside cftransaction if an error occurs then set a variable to no...

annd before sending the email check wether the variables value is yes or not...

Regards
Hart
0
 

Author Comment

by:MMsabry
ID: 11971323
That might work, but do you know why the insert does not function when the cfmail tag is there?
i can understand if everything is wrapped in a cftransaction, but when this is not the case!
0
 

Author Comment

by:MMsabry
ID: 11972303
Hart,
Thanks for the ideas, they work, but i made a small modification!
I just initialized a variable default "0", and in the transaction i set it to value "1"
I use a cfif statement, if evaluates to true, i include the e-mail template.
Although i think your solution of stored procedures is more elegant, I have no experience with stored procedures!
thanks once more
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question