Solved

simple query question for big points!!

Posted on 2006-10-24
4
174 Views
Last Modified: 2013-12-24
Hello,

I am trying to set up a newsletter program for a client
but am having trouble getting the program to insert the
subscribers first name and email into the mailto script.

Here is the query I am using and the code I am using to
try and send the emails.

<cfquery name="send" datasource="#dsn#" username="#user#" password="#pass#">
SELECT fName, email
FROM NEWSLETTER
WHERE active = '1'
</cfquery>

<cfmail to="#send.email#" from="newsletter@oldfarmkennels.com" subject="#send.fName#, #subject#">
Dear #send.fName#,

#copy#
***********************************************************
If you are receiving this in error or no longer wish to
receive this newsletter simply click on the link below to
be removed from any future mailings.

http://www.oldfarmkennels.com/ezine/unsubscribe.cfm
</cfmail>

<cflocation url="../ezine/success.cfm" addtoken="yes">

Thanks in advance for your help.

Sincerely,
Brandon
0
Comment
Question by:brandonpowell
4 Comments
 
LVL 12

Accepted Solution

by:
mkishline earned 500 total points
ID: 17799541
There are two ways you can do this:
1) Wrap your cfmail in a cfoutput:

<cfoutput query="send">
  <cfmail to="#send.email#" from="newsletter@oldfarmkennels.com" subject="#send.fName#, #subject#">
    ...
  </cfmail>
</cfoutput>

2) Use the query attribute of the cfmail tag:

<cfmail to="#send.email#" from="newsletter@oldfarmkennels.com" subject="#send.fName#, #subject#" query="send">
  ...
</cfmail>

Pick whichever one works cleanest for you.
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 17799554
doesn't appear that there's anything wrong with the code..except it will only give you one record... are you getting an error?


you want to either use cfloop or cfoutput to output all

<cfquery name="send" datasource="#dsn#" username="#user#" password="#pass#">
SELECT fName, email
FROM NEWSLETTER
WHERE active = '1'
</cfquery>


<cfloop query="send">
<cfmail to="#send.email#" from="newsletter@oldfarmkennels.com" subject="#send.fName#, #subject#">
Dear #send.fName#,

#copy#
***********************************************************
If you are receiving this in error or no longer wish to
receive this newsletter simply click on the link below to
be removed from any future mailings.

http://www.oldfarmkennels.com/ezine/unsubscribe.cfm
</cfmail>
</cfloop>


or

<cfquery name="send" datasource="#dsn#" username="#user#" password="#pass#">
SELECT fName, email
FROM NEWSLETTER
WHERE active = '1'
</cfquery>

<cfoutput query="send">
<cfmail to="#send.email#" from="newsletter@oldfarmkennels.com" subject="#send.fName#, #subject#">
Dear #send.fName#,

#copy#
***********************************************************
If you are receiving this in error or no longer wish to
receive this newsletter simply click on the link below to
be removed from any future mailings.

http://www.oldfarmkennels.com/ezine/unsubscribe.cfm
</cfmail>
</cfoutput>


0
 
LVL 5

Expert Comment

by:rucky544
ID: 17819663
Do you mean

WHERE active = 1 <!--- this is if active is true, where as '1' would mean where active = 1 (as a string) --->

I don't know if your problem is that simple?
0
 
LVL 1

Expert Comment

by:ctdigital
ID: 17839868
<cfquery name="send" datasource="#dsn#" username="#user#" password="#pass#">
SELECT fName, email
FROM NEWSLETTER
WHERE active = 1
</cfquery>

<cfmail to="#send.email#" from="newsletter@oldfarmkennels.com" subject="#send.fName#, #subject#">
Dear #send.fName#,

#copy#

If you are receiving this in error or no longer wish to
receive this newsletter simply click on the link below to
be removed from any future mailings.

http://www.oldfarmkennels.com/ezine/unsubscribe.cfm
</cfmail>

<script>
      self.location="../ezine/success.cfm";
</script>


See if using javascript helps instead of using <cflocation> - Maybe I'm foolish but I remember having a similar issue to yours when I first started out in coldfusion.  Try using <script> self.location instead of <cflocation>
0

Featured Post

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
php.ini on ipage hosting 12 47
Unable To Access a Web Domain From Our Network 16 84
Firewall Speed Issue 6 66
SSL sertificate 5 57
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

919 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now