Solved

CFMAIL sending email twice!

Posted on 2003-11-28
13
360 Views
Last Modified: 2013-12-24
Hi,

I created an online library where people can check out books etc. I have a section where the library owner can send emails to the people whose books are overdue. However, whenever that process is run, two emails are sent to each person. I have no clue what could cause this.

I have a cfquery that grabs the information for the people who are overdue. Then I call the query within my cfmail. Here's the code:

<cfquery name="qryOverdue" datasource="library">
SELECT Loans.LoanIndex, Loans.Title, Loans.Name, Loans.Email, Loans.Date_Out, Loans.Date_Due
FROM Loans
WHERE ((Now()>[Loans]![Date_Due]))
</cfquery>

<cfmail
to="#qryOverdue.Email#"
from="library_mailbox@company.com"
subject="overdue learning library item"
query="qryOverdue"
server="company_exchange_server.com"
port="25"
type="html">
<cfmailparam name="X-Priority" value="1">
Greetings,<p>
The item you checked out on #DateFormat(qryOverdue.Date_Out, 'mm/dd/yyyy')#,
"#qryOverdue.Title#", was due back #DateFormat(qryOverdue.Date_Due, 'mm/dd/yyyy')#.<p>
Please return this item to the Learning Library ASAP.<p>
Thank you!
</cfmail>
0
Comment
Question by:makila
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
13 Comments
 
LVL 12

Expert Comment

by:jyokum
ID: 9840435
<cfquery name="qryOverdue" datasource="library">
SELECT Loans.LoanIndex, Loans.Title, Loans.Name, Loans.Email, Loans.Date_Out, Loans.Date_Due
FROM Loans
WHERE ((Now()>[Loans]![Date_Due]))
</cfquery>

<cfoutput query="qryOverdue">
    sending mail to #qryOverdue.Email#<br> <!--- this is just for debugging --->
    <cfmail
        to="#qryOverdue.Email#"
        from="library_mailbox@company.com"
        subject="overdue learning library item"
        server="company_exchange_server.com"
        port="25"
        type="html">
        <cfmailparam name="X-Priority" value="1">
Greetings,<p>
The item you checked out on #DateFormat(qryOverdue.Date_Out, 'mm/dd/yyyy')#,
"#qryOverdue.Title#", was due back #DateFormat(qryOverdue.Date_Due, 'mm/dd/yyyy')#.<p>
Please return this item to the Learning Library ASAP.<p>
Thank you!
    </cfmail>
</cfoutput>
0
 

Author Comment

by:makila
ID: 9840458
I should also add this tidbit. I replaced #qryOverdue.Email# with my own email and still received two emails for each overdue item.
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9840675
are you sure your query is only returning 1 record? try dumping the recordset to see what's being returned

<cfdump var="#qryOverdue#">
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:makila
ID: 9840906
I will try that when I get back to work on Monday :)
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 9841497
You probably need to group your query in the mail tag, look at the cfmail attribute GROUP
0
 

Author Comment

by:makila
ID: 9851963
The query is returning 10 unique records now (books have been returned!) and sending 20 emails. I upgraded to Coldfusion MX 6.1 in hopes that maybe it was a server bug but no such luck. I checked the mailsent.log and it shows 20 emails being sent.

I Googled to see if anyone else has had the same problems and I found a couple others but they never found resolutions.
0
 

Author Comment

by:makila
ID: 9852100
Previous message is referring to the results I got from dumping the recordset, btw. I also tried grouping the query in the mail tag by "LoanIndex" but I still got 20 emails. Ack.
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 9852589
is the mail tag wrapped in another custom tag? If so, does this tag end with \> ?
0
 

Author Comment

by:makila
ID: 9852702
I kind of have it figured out now. Somehow, the way I linked to the page with cfmail made it run twice.

This simple link works and it only emails once:

Click <a href="library_overdue_II.cfm">here</a> to send an email reminder to all overdue loanees.

This link pops up a small window and after the cfmail sends, the windows says "Reminders have been sent." This sends the emails twice:

Click <a href="library_overdue_II.cfm" target="send_reminders" onClick="window.open('library_overdue_II.cfm','send_reminders','width=500,height=325,top=150,left=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=1')" class="no_under">here</a> to send an email reminder to all overdue loanees.
0
 
LVL 12

Accepted Solution

by:
jyokum earned 100 total points
ID: 9855838
change it to

Click <a href="#" target="send_reminders" onClick="window.open('library_overdue_II.cfm','send_reminders','width=500,height=325,top=150,left=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=1')" class="no_under">here</a> to send an email reminder to all overdue loanees.
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

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…
What You Need to Know when Searching for a Webhost Provider
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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