IShiva
asked on
Sending emails to checked address only
I have a database table that holds info about players on a soccer team. Name, Number, Position etc. I added the field 'PlayerEmail' to the table. After the coach logs in, I want him to be able to send emails to the entire team OR to individual players that he checks. (I would have a 'Send to all' link, a 'Send to Varsity' link and a 'Send to Junior Varsity' link at the top of the page so he doesn't have to check 20some boxes to send emails to a particular team. He does need the ability to send an email to just 1 or 2 players though, and I'm a bit stumped. I would like the coach to be able to check 1 or some of the players then be sent to a page with a form (textarea) where he can then type his email. He would then click send, and the email would only be sent to the checked players. In my mind this would have to be 3 pages.....ViewPlayers.cfm (where the player info and the 'send email to' checkbox would be)......ComposeEmail.cfm (where the coach would type in a textarea to provide the email content).....and the ComposeMailAction.cfm (where the cfmail would execute and mail to only checked players) I know how to code the 'Send to Varsity' or 'Send to All' piece, and am have a little bit of knowledge on cfmail but am baffled when it comes to checkboxes. Does anyone have an idea? Your help is appreciated.
IShiva
IShiva
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You'd need a cfquery on ViewPlayers.cfm to pull the names and email addresses of the players so you can output them. Other than that, you'd only need a cfquery if you need information that won't be provided by the user through the forms. Keep in mind that any information you want to pass from ViewPlayers.cfm to ComposeMailAction.cfm needs to be passed from ViewPlayers.cfm->ComposeEm ail.cfm->C omposeMail Action.cfm . ComposeMailAction.cfm cannot directly access any form or other variables from ViewPlayers.cfm.
ASKER
ok, can you please doublecheck my code below. It goes through just fine without error, but no emails are sent. Is my code incorrect?
<--- SendEmailAction.cfm -->
<cfloop index="i" list="#form.PlayerEmail#">
<cfmail to="#i#"
from="myemail@domain.com
subject="#form.Subject#" type="html">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table>
email content will go here
</body>
</html>
</cfmail>
</cfloop>
<cflocation url="ThankYou.cfm">
<--- SendEmailAction.cfm -->
<cfloop index="i" list="#form.PlayerEmail#">
<cfmail to="#i#"
from="myemail@domain.com
subject="#form.Subject#" type="html">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table>
email content will go here
</body>
</html>
</cfmail>
</cfloop>
<cflocation url="ThankYou.cfm">
Your table is not quite right, (missing <tr><td> and ending </table>) but I doubt that is the cause of the problem. For testing purposes, try changing your code on the SendEmailAction page to this:
<cfloop index="i" list="#form.PlayerEmail#">
Send email to: #i#<br />
</cfloop>
<cfabort />
If the email addresses don't show up on the page, then change the code to:
<cfdump var="#form#" />
<cfabort />
Check the PlayerEmail field and see what, if any values are being passed into that. If the value in PlayerEmail is #form.PlayerEmail# then on ComposeEmail.cfm make sure that your <input type="hidden" name="PlayerEmail" value="#form.PlayerEmail#" /> tag is wrapped inside of a <cfoutput>
<cfloop index="i" list="#form.PlayerEmail#">
Send email to: #i#<br />
</cfloop>
<cfabort />
If the email addresses don't show up on the page, then change the code to:
<cfdump var="#form#" />
<cfabort />
Check the PlayerEmail field and see what, if any values are being passed into that. If the value in PlayerEmail is #form.PlayerEmail# then on ComposeEmail.cfm make sure that your <input type="hidden" name="PlayerEmail" value="#form.PlayerEmail#"
ASKER
ok ill check those things and post back...Thanks!!!
ASKER
I didn't have <input type="hidden" name="PlayerEmail" value="#form.PlayerEmail#" /> surrounded in a <cfoutput>. Works perfect now!!
One last thing, on the ComposeEmail.cfm page I have a textbox and textarea where the coach types the email. I also have a list of the recipients that he has chosen from the previous page. I cant seem to get that list to go up and down. It is a comma delimited list and makes my page very wide. Is there a way to view the comma delimited list up and down? Like in multiple <tr>'s? Here is my code for that section. I even tried surrounding the <tr> in a cfoutput but that didnt work either. Any suggestions on this?
<table cellpadding="2" cellspacing="0">
<tr>
<td><strong>Email recipients:</strong></td>
</tr>
<tr>
<td><font size="-2"><cfoutput><br>#f orm.Player Email#</cf output></f ont></td>
</tr>
</table>
One last thing, on the ComposeEmail.cfm page I have a textbox and textarea where the coach types the email. I also have a list of the recipients that he has chosen from the previous page. I cant seem to get that list to go up and down. It is a comma delimited list and makes my page very wide. Is there a way to view the comma delimited list up and down? Like in multiple <tr>'s? Here is my code for that section. I even tried surrounding the <tr> in a cfoutput but that didnt work either. Any suggestions on this?
<table cellpadding="2" cellspacing="0">
<tr>
<td><strong>Email recipients:</strong></td>
</tr>
<tr>
<td><font size="-2"><cfoutput><br>#f
</tr>
</table>
This should work:
<table cellpadding="2" cellspacing="0">
<tr>
<td><strong>Email recipients:</strong></td>
</tr>
<tr>
<td><font size="-2"><cfoutput><cfloo p index="i" list="#form.PlayerEmail#"> #i#<br /></cfloop></cfoutput></fo nt></td>
</tr>
</table>
<table cellpadding="2" cellspacing="0">
<tr>
<td><strong>Email recipients:</strong></td>
</tr>
<tr>
<td><font size="-2"><cfoutput><cfloo
</tr>
</table>
ASKER
how bout that....i actually figured that one out on my own.....here is what i did..can you tell me if this is acceptable? It works, but will it give me problems later on?
<cfset list = "#form.PlayerEmail#">
<td valign="top">
<table cellpadding="2" cellspacing="0">
<tr>
<td><strong>Email recipients:</strong></td>
</tr>
<cfloop list="#list#" index="i">
<tr>
<td><font size="-2"><cfoutput>#i#</c foutput></ font></td>
</tr>
</cfloop>
</table>
</td>
<cfset list = "#form.PlayerEmail#">
<td valign="top">
<table cellpadding="2" cellspacing="0">
<tr>
<td><strong>Email recipients:</strong></td>
</tr>
<cfloop list="#list#" index="i">
<tr>
<td><font size="-2"><cfoutput>#i#</c
</tr>
</cfloop>
</table>
</td>
No problems with that at all. Well done and happy coding! :-)
ASKER
Thanks!! I appreciate all your help!
IShiva
IShiva
ASKER