CFMAIL Looping

I have an application that I've written so that a user can
send a group of people an email message. It is in two parts, the
form and the action page that actually sends the email. The first
page's code is as follows:
<cfquery name="getEmail"
datasource="#application.dsn#">
SELECT *
FROM tblEpolarityRPP_new
ORDER BY EMAIL
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<html>
<head>
<title>Email RPPs</title>
<link rel="stylesheet" type="text/css"
href="organized.css">
</head>
<body>
<h2>Email RPPs</h2>
<cfform action="rppemail_actiontest.cfm" method="post">
<cfoutput query="getEmail">
<!--- #getEmail.Email#<br> --->
<input type="hidden" name="Email"
value="#getEmail.Email#">
</cfoutput>
<p class="p5">Enter message here:<br>
<textarea name="Message" rows="20"
cols="50"></textarea><p>
<input type="submit" value="Send
Email">  <input type="reset" value="Clear
Form">
</cfform>
</body>
</html>
The query retrieves about 710 email addresses from the table.
When we submit, it apparently works okay, but according to the host
of our web site, there are too many email addresses in the list and
it doesn't send any because it hangs. I know that what the action
page is doing is creating an email with 710 email addresses in the
"TO" line. What I would like it to do is create 710 different
emails, with one of the email addresses from the database in each
message. According to the tech support person at the hosting site,
this should fix the problem. The code on the action page is:
<cfmail to="#Form.Email#"
from="[email protected]" subject="ePolarity"
type="html" server="mail.polarityinbalance.com">
#Form.Message#
</cfmail>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<html>
<head>
<title>Email RPP Results</title>
</head>
<body>
Your email was successfully transmitted.<p>
<a href="polarityadminindex.cfm">Click here</a>
to return to the Administrator menu.
</body>
</html>
Any suggestions on how to create a loop to insert one email
address at a time into the email would be greatly appreciated.
Thanks so much,
Michelle Craig

look into this document
http://127.0.0.1:8500/cfdocs/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm

Similar Messages

  • Cfmail loops back to original form document yet not sending email.

    I had produced a form to be emailed. after one finishes the form and press submit it loops back top the form again, yet i do not get an email. Doen anyone know why this is happening? Below is the code for the original form and below that is code to my action page... Any suggestions would be welcomed..
    FORM ORIGINAL CODE
    <cfquery name="select_ministry" datasource="ministry9">
    SELECT ministry.ministry
    FROM ministry
    ORDER BY ministry.ministry
    </cfquery>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    @import url("CSS/event_Req_Label.css");
    -->
    </style>
    </head>
    <body>
    <!--- Begin ColdFusion Form --->
    <cfform name="Event_Request" action="EventRequestSend.cfm" method="post" >
    <strong>Event Contact</strong><br />
    <br />
      <span class="eventReq_label">First Name:</span>
                        <cfinput
                        type="text"
                        name="First_Name"
                        message="Please enter your First Name..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Last Name:</span>
                          <cfinput
                        type="text"
                        name="Last_Name"
                        message="Please enter your Last Name..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Phone:</span>
                          <cfinput
                        type="text"
                        name="Phone"
                        message="Please enter your Phone Number..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Email:</span>
                          <cfinput
                        type="text"
                        name="Email_Address"
                        message="Please enter your Email Address..."
                        required="yes" class="event_Request_Box"
                        size="30">
                        </span><br />
                          <br />
                        <br />
                          <strong>About Event/Program</strong><br />
                        <br />
                          <span class="eventReq_label">Event Title:</span>
                          <cfinput
                        type="text"
                        name="Event_Title"
                        message="Please enter the Name of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <br />
                          <span class="eventReq_label">Ministry: </span>
                               <select name="select_ministry" size="1" class="event_Request_Box">
                                 <cfoutput query="select_ministry">
                                   <option value= "#select_ministry.Ministry#" <cfif (isDefined("select_ministry.Ministry") AND select_ministry.Ministry EQ select_ministry.Ministry)>selected</cfif>>#select_ministry.Ministry#</option>
                                 </cfoutput>
                                 </select>
                               <br />
                          <span class="eventReq_label">Event Description:</span>
                          <cftextarea name="Event_Description" cols="40" rows="10" label="Event_Description" required="yes" class="event_Request_Box" id="Event_Description" message="Please Enter a description for the event." tooltip="Please Describe the event in 75 words or less." enabled="no" value="Event_Description" maxlenght="75"></cftextarea>
                          <br />
                          <span class="eventReq_label">Event Date:</span>
                          <cfinput
                        type="text"
                        name="Event_Date"
                        message="Please enter the Date of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Event Time:</span>
                          <cfinput
                        type="text"
                        name="Event_Time"
                        message="Please enter the Time of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Address:</span>
             <cfinput
                        type="text"
                        name="Event_address"
                        message="Please enter the Address of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                        <br />
                          <span class="eventReq_label">Address 2:</span>
                          <cfinput
                        type="text"
                        name="Event_address_2"
                        message="Please enter the Address of the Event..."
                        required="no" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">City:</span>
                          <cfinput
                        type="text"
                        name="Event_City"
                        message="Please enter the City of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">State:</span>
                          <cfinput
                        type="text"
                        name="Event_State"
                        message="Please enter the State of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Zipcode:</span>
                          <cfinput
                        type="text"
                        name="Event_Zip_code"
                        message="Please enter the Zip Code of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Admission Cost:</span>
                          <cfinput
                        type="text"
                        name="admission_Cost"
                        message="Please enter the cost of admission for the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                        <br />
                        <input type="submit" name="Submit" class="submit" value="Submit">
                        <br />
                        <br />
             <!--- End ColdFusion Form --->
                        </cfform>
    </body>
    </html>
    FORM ACTION PAGE CODE
    <!--- Add cfparams to prevent errors on the page --->
    <cfparam name="Event_Request.First_Name" default="">
    <cfparam name="Event_Request.Last_Name" default="">
    <cfparam name="Event_Request.Phone" default="">
    <cfparam name="Event_Request.Email_address" default="">
    <cfparam name="Event_Request.Event_title" default="">
    <cfparam name="Event_Request.select_ministry" default="">
    <cfparam name="Event_Request.Event_Description" default="">
    <cfparam name="Event_Request.Event_Date" default="">
    <cfparam name="Event_Request.Event_Time" default="">
    <cfparam name="Event_Request.Event_address" default="">
    <cfparam name="Event_Request.Event_address_2" default="">
    <cfparam name="Event_Request.Event_City" default="">
    <cfparam name="Event_Request.Event_State" default="">
    <cfparam name="Event_Request.Event_Zip_code" default="">
    <cfparam name="Event_Request.admission_Cost" default="">
    <!--- Create an empty error string --->
    <cfset strError = "">
    <!--- If the form is submitted --->
    <cfif isDefined("Event_Request.Submit")>
    <!--- If the First Name field is empty --->
        <cfif Len(Trim(Event_Request.First_Name)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter your First Name...<br>">
        </cfif>
    <!--- If the Last Name field is empty --->
        <cfif Len(Trim(Event_Request.Last_Name)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter your Last Name...<br>">
        </cfif>
        <!--- If the Phone field is empty --->
        <cfif Len(Trim(Event_Request.Phone)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter your Phone Number...<br>">
        </cfif>
        <!--- If the Email field is empty --->
        <cfif Len(Trim(Event_Request.Email_address)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter your Email Address...<br>">
        </cfif>
        <!--- If the Event_title field is empty --->
        <cfif Len(Trim(Event_Request.Event_title)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the Name of the Event...<br>">
        </cfif>
    <!--- If the select_ministry is empty --->
        <cfif Len(Trim(Event_Request.select_ministry)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please select the ministry...<br>">
        </cfif>
    <!--- If the Event_Description is empty --->
        <cfif Len(Trim(Event_Request.Event_Description)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "please include your description...<br>">
        </cfif>
    <!--- If the Event_Date is empty --->
        <cfif Len(Trim(Event_Request.Event_Date)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the date of your program...<br>">
        </cfif>
    <!--- If the Event_Time is empty --->
        <cfif Len(Trim(Event_Request.Event_Time)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the Time of your program...<br>">
        </cfif>
    <!--- If the Event_address is empty --->
        <cfif Len(Trim(Event_Request.Event_address)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the address of your program...<br>">
        </cfif>
    <!--- If the Event_City is empty --->
        <cfif Len(Trim(Event_Request.Event_City)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the city of your program...<br>">
        </cfif>
    <!--- If the Event_State is empty --->
        <cfif Len(Trim(Event_Request.Event_State)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the state of your program...<br>">
        </cfif>
    <!--- If the Event_Zip_code is empty --->
        <cfif Len(Trim(Event_Request.Event_Zip_code)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the zipcode of your program...<br>">
        </cfif>
    <!--- If the admission_Cost is empty --->
        <cfif Len(Trim(Event_Request.admission_Cost)) LT 1>
            <!--- Add this to the error string --->
            <cfset strError = strError & "Please enter the Admission Cost of your program...<br>">
        </cfif>
    <!--- If the form was not submitted --->
    <cfelse>
        <!--- Send the user to the form page --->
        <cflocation addtoken="no" url="Event_Request.cfm">
    </cfif>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Response Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    @import url("CSS/event_Req_Label.css");
    -->
    </style>
    </head>
    <body>
    <!--- If the error string is still empty show the results --->
    <cfif strError EQ "">
        <p>Thank you for submitting the Event Request form.</p>
        <p>You submitted the following information:</p>
        <cfoutput>
            <p>    First Name:     #Trim(EVENT_REQUEST.First_Name)#<br><br>
                Last Name:     #Trim(EVENT_REQUEST.Last_Name)#<br><br>
                      Phone:         #Trim(EVENT_REQUEST.Phone)#<br><br>
                Email:         #Trim(EVENT_REQUEST.Email_Address)#<br><br><br><br>
                Event Title:     #Trim(EVENT_REQUEST.Event_Title)#<br><br>
                Ministry:     #Trim(EVENT_REQUEST.select_ministry)#<br><br>
                Description:     #Trim(EVENT_REQUEST.Event_Description)#<br><br>
                Event Date:     #Trim(EVENT_REQUEST.Event_Date)#<br><br>
                Event Time:     #Trim(EVENT_REQUEST.Event_Time)#<br><br>
                Event Address:     #Trim(EVENT_REQUEST.Event_address)#<br><br>
                Event Address 2:#Trim(EVENT_REQUEST.Event_address_2)#<br><br>
                Event City:     #Trim(EVENT_REQUEST.Event_City)#<br><br>
                Event State:     #Trim(EVENT_REQUEST.Event_State)#<br><br>
                Zip code:     #Trim(EVENT_REQUEST.Event_Zip_code)#<br><br>
          Admission_Cost:    #Trim(EVENT_REQUEST.admission_Cost)#<br><br></p>
        </cfoutput>
        <p>Someone will contact you if necessary. </p>
    <!--- Send the email --->
    <cfmail from="#EVENT_REQUEST.Email_Address#"         to="[email protected]"
            subject="You have mail from"
            replyto="#EVENT_REQUEST.Email_Address#"
            server="mail.thehansonco.com">
    You Have an inquiry from:     #Trim(EVENT_REQUEST.First_Name)#
                                #Trim(EVENT_REQUEST.Last_Name)#<br><br>
                          Phone:     #Trim(EVENT_REQUEST.Phone)#<br><br>
                        Email:     #Trim(EVENT_REQUEST.Email_Address)#<br><br><br><br>
                        Event Title:     #Trim(EVENT_REQUEST.Event_Title)#<br><br>
                        Ministry:         #Trim(EVENT_REQUEST.select_ministry)#<br><br>
                        Description:     #Trim(EVENT_REQUEST.Event_Description)#<br><br>
                        Event Date:     #Trim(EVENT_REQUEST.Event_Date)#<br><br>
                        Event Time:     #Trim(EVENT_REQUEST.Event_Time)#<br><br>
                        Event Address:     #Trim(EVENT_REQUEST.Event_address)#<br><br>
                        Event Address 2:#Trim(EVENT_REQUEST.Event_address_2)#<br><br>
                        Event City:     #Trim(EVENT_REQUEST.Event_City)#<br><br>
                        Event State:     #Trim(EVENT_REQUEST.Event_State)#<br><br>
                        Zip code:         #Trim(EVENT_REQUEST.Event_Zip_code)#<br><br>
                        Admission_Cost:    #Trim(EVENT_REQUEST.admission_Cost)#<br><br>
        </cfmail>
    <!--- If the error string is not empty show the form again --->
        <cfelse>
        <!--- Begin ColdFusion Form --->
    <cfform name="Event_Request"  action="EventRequestSend.cfm" method="post" >
    <strong>Event Contact</strong><br />
    <br />
    <!--- Add table row to show error message --->
                    <cfoutput>#strError#</cfoutput>
      <span class="eventReq_label">First Name:</span>
                        <cfinput
                        type="text"
                        name="First_Name"
                        message="Please enter your First Name..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Last Name:</span>
                          <cfinput
                        type="text"
                        name="Last_Name"
                        message="Please enter your Last Name..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Phone:</span>
                          <cfinput
                        type="text"
                        name="Phone"
                        message="Please enter your Phone Number..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Email:</span>
                          <cfinput
                        type="text"
                        name="Email_Address"
                        message="Please enter your Email Address..."
                        required="yes" class="event_Request_Box"
                        size="30">
                        </span><br />
                          <br />
                        <br />
                          <strong>About Event/Program</strong><br />
                        <br />
                          <span class="eventReq_label">Event Title:</span>
                          <cfinput
                        type="text"
                        name="Event_Title"
                        message="Please enter the Name of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <br />
                          <span class="eventReq_label">Ministry: </span>
                               <select name="select_ministry" size="1" class="event_Request_Box">
                                 <cfoutput query="select_ministry">
                                   <option value= "#select_ministry.Ministry#" <cfif (isDefined("select_ministry.Ministry") AND select_ministry.Ministry EQ select_ministry.Ministry)>selected</cfif>>#select_ministry.Ministry#</option>
                                 </cfoutput>
                                 </select>
                               <br />
                          <span class="eventReq_label">Event Description:</span>
                          <cftextarea name="Event_Description" cols="40" rows="10" label="Event_Description" required="yes" class="event_Request_Box" id="Event_Description" message="Please Enter a description for the event." tooltip="Please Describe the event in 75 words or less." enabled="no" value="Event_Description" maxlenght="75"></cftextarea>
                          <br />
                          <span class="eventReq_label">Event Date:</span>
                          <cfinput
                        type="text"
                        name="Event_Date"
                        message="Please enter the Date of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Event Time:</span>
                          <cfinput
                        type="text"
                        name="Event_Time"
                        message="Please enter the Time of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Address:</span>
             <cfinput
                        type="text"
                        name="Event_address"
                        message="Please enter the Address of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                        <br />
                          <span class="eventReq_label">Address 2:</span>
                          <cfinput
                        type="text"
                        name="Event_address_2"
                        message="Please enter the Address of the Event..."
                        required="no" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">City:</span>
                          <cfinput
                        type="text"
                        name="Event_City"
                        message="Please enter the City of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
      <span class="eventReq_label">State:</span>
      <cfinput
                        type="text"
                        name="Event_State"
                        message="Please enter the State of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
    <br />
                          <span class="eventReq_label">Zipcode:</span>
                          <cfinput
                        type="text"
                        name="Event_Zip_code"
                        message="Please enter the Zip Code of the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                          <span class="eventReq_label">Admission Cost:</span>
                          <cfinput
                        type="text"
                        name="admission_Cost"
                        message="Please enter the cost of admission for the Event..."
                        required="yes" class="event_Request_Box"
                        size="30">
                          <br />
                        <br />
                        <input type="submit" name="Submit" class="submit" value="Submit">
                        <br />
                        <br />
                        </cfform>
                        </cfif>
    </body>
    </html>

    When you submit a form, the name of it doesn't matter.  When you process it it's form.this and form.that, not name_of_form.this and name_of_form.that.  In your code, the structure event_request does not exist until the cfparam tags create it.  All of those tags will create variables with empty strings.  Later your code adds a bunch of error messages and doesn't send any mail because of your if/else logic.

  • Cfmail loop query

    can some one help me with this query please
    i have a cfmail running off a query
    i want to be able to send mail to a list of recipietns from
    my database
    the query below works but only sends emails to the first
    contact in the list
    what can i do to my query to change this?
    <CFQUERY datasource="#application.ds#" Name="GetSch">
    SELECT cc.Code, gg.PlayerPhone, dd.Message, cc.Club_Abbrev
    FROM appoint_table dd, SMS_Players_Table gg, SMS_Clubs_Table
    cc
    WHERE ServerSMS <= #CreateODBCDateTime(Now())# AND
    dd.App_ClientID = gg.PlayerID AND dd.LoginID = cc.ClubID
    AND ServerSMS <> ''
    </cfquery>
    <cfmail to = "[email protected]" query="GetSch"
    from = "test"
    subject="">
    to:#Code##PlayerPhone#
    text:#Message#
    from:#Club_Abbrev#
    </cfmail>

    ok thank i just realised what i need
    just to go to one email as the cfmail is at the min
    but i need to loop through the mail output so it send 30
    emails to the same email
    with the different
    to:#Code##PlayerPhone#
    text:#Message#
    from:#Club_Abbrev#
    for each record retreved form the query

  • CFMAIL Any Faster In CF8? How many mails per minute?

    Hi there,
    We are currently running CF 7.02 and are considering
    upgrading to 8.
    I've seen lots of articles extolling the speed increases in
    CF8 over 7 etc. but I wondered if there was much of a performance
    increase in regards to CFMAIL?
    We send out vast quantities of emails every day and at busy
    times CFMAIL struggles to keep up. Mails seem to be sent out quick
    enough to our mail server but it seems to be the physical process
    of creating the cfmail files ready for sending that is a little
    slow.
    I think I read somewhere that under CF7 CFMAIL could create
    about 600 CFMAIL files a minute. Does anyone know what the figure
    is for CFMAIL under CF8?
    Or does anyone have any real world experience of CFMAIL
    speeding up or slowing down following an upgrade from CF 7 to 8?
    If this is still slow does anyone have any experience of
    using third party, dedicated, products to do what CFMAIL does? The
    mails we send are stored as entries in our SQL DB and we currently
    use CFMAIL to query the DB and produce html and plain text emails
    from these entries. Is there anything that we coul use to do that
    and take CFMAIL out of the loop?
    Cheers,
    Tem

    Hi there,
    We are currently running CF 7.02 and are considering
    upgrading to 8.
    I've seen lots of articles extolling the speed increases in
    CF8 over 7 etc. but I wondered if there was much of a performance
    increase in regards to CFMAIL?
    We send out vast quantities of emails every day and at busy
    times CFMAIL struggles to keep up. Mails seem to be sent out quick
    enough to our mail server but it seems to be the physical process
    of creating the cfmail files ready for sending that is a little
    slow.
    I think I read somewhere that under CF7 CFMAIL could create
    about 600 CFMAIL files a minute. Does anyone know what the figure
    is for CFMAIL under CF8?
    Or does anyone have any real world experience of CFMAIL
    speeding up or slowing down following an upgrade from CF 7 to 8?
    If this is still slow does anyone have any experience of
    using third party, dedicated, products to do what CFMAIL does? The
    mails we send are stored as entries in our SQL DB and we currently
    use CFMAIL to query the DB and produce html and plain text emails
    from these entries. Is there anything that we coul use to do that
    and take CFMAIL out of the loop?
    Cheers,
    Tem

  • How can I put a timed pause between CFMAIL sendouts?

    A preface, this is not marketing e-mailing I'm discussing, it's already opted-in government notifications requested by the customers.
    This is driving me absolutely crazy.  I've got a working SQL query that pulls a number or records (e-mail addresses), then sends out a series of mailings in batches (still working on that part).
    What I'm stuck on is how in the world can I pause the CFMAIL processings between batches?  For example, I want to send 500 e-mails, pause for 10 minutes, send the next 500, etc.
    CFTHREAD looks kinda like what I might need but I'm not sure.
    We're afraid of sending all at once (probably no more than 5,000 to 10,000 total) in fear of being blacklisted.  Usually this app will only send 100 to 500 at a time.
    Thanks in advance for any help you guys can give!
    This is for CF8, incidentally.
    T

    I've developed a mailing application like this for our own (used for sending up to 100k emails per job so far without a problem) and my solution was this (simplified):
    1) set-up a CFusion cronjob that runs every X minutes and executes the following
    2) select all records/email-addresses within the sql query (no maxrows parameter)
    3) cfloop over this query result-set with startrow and endrow parameter to select just the desired number of addresses
    4) stored endrow value in database and used this one as startrow param for the next run/loop, X minutes later... and so on
    I do not think that using cfsleep is wise, as such mailingjobs could potientially run for hours if not days, and you don't want to let scripts run this long.
    First they occupy one of the precious "max parallel cf threads" slots on your server and second you could potentially loose all progress of this task if your server ever restarts while this script is running.

  • CFMAIL and adding CC if needed

    I am currently looping over a list of email addresses and
    sending out the
    mail to all users. I'd like to instead check to see if a
    variable is set,
    and add the cc="" in the cfmail tag instead.
    When I try this it fails, I simply did a <cfif MailCC neq
    "">cc="[email protected]"</cfif> in the cfmail tag, but
    it doesn't seem to like
    this.
    Has anyone done anything similar?
    Or how can I get this to work?
    Thanks!

    i have not tried it, but i know several ways to make it work:
    1) put your whole CFMAIL tag inside a cfif block checking for
    MailCC var
    . you will have 2 complete cfmail tags - one executed when
    MailCC var
    exists (this one will have the cc=".." attribute in it),
    another
    (without cc) executed when MailCC var is empty:
    <cfif len(trim(MAilCC))>
    <cfmail cc="..." ...>
    </cfmail>
    <cfelse>
    <cfmail ...><!--- no cc attrib in this one --->
    </cfmail>
    </cfif>
    2) use attributeCollection attribute of cfmail tag. assumes
    you are on
    cf8. (or is it only update 1 that allows using
    attributeCollection
    together with in-tag attributes? if so, you have to be on
    cf8.0.1).
    something like:
    <cfscript>
    mailAttr = {};
    mailAttr.server = "mail.somedomain.com";
    mailAttr.username = "...";
    mailAttr.password = "...";
    mailAttr.from = "[email protected]";
    mailAttr.subject = "mail subject here";
    if (len(trim(MailCC)) gt 0)
    mailAttr.cc = "[email protected]";
    </cfscript>
    <cfmail to="..." attributeCollection="#mailAttr#">
    </cfmail>
    hth
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • CFMAIL Attached vs. embedded (cfmail, multipart/mixed)

    I want to send a mail which has a PDF attachment and an embedded image. When I send them both with cfmailparam (with correct disposition) they arrive in the email as attachments in the body...you don't get the little email paperclip attachment icon.
    When I tried using mimeattach for the PDF it did work!...but the image denoted with cfmailparam also came through like that. So I looked the email headers of both and the good one was Content-Type: multipart/mixed; while the bad one was "multipart/related".
    So how can I make cfmailparam send it as multipart/mixed? (if that's even the right question...maybe I should stick with mimeattach and do something else?)
    Thanks Folks' - Randy

    I never found a solution using cfmail.  I had to resort to java instead.
    I have all of my file information (including content) in a query called qFiles and loop through that in the code below.
    <cfscript>
        // config will stay this way
        emailServer = serverAddressHere;
        emailServerAccount = "";
        emailServerPwd = "";
        //  set email variables
        vSentFrom = sentFromEmailHere;
        vSubjectText = subjectHere;
        recipientsTo = listToArray( SentToListHere );
        recipientsCC = listToArray( CCListHere );
        recipientsBCC = listToArray( BCCListHere );
        // set javamail properties
        props = createObject("java", "java.util.Properties").init();
        props.put("javax.mail.smtp.host", emailServer);
        // get static recipient types
        recipientType = createObject("java", "javax.mail.Message$RecipientType");
        // create the session for the smtp server
        mailSession = createObject("java", "javax.mail.Session").getInstance(props);
        // create a new MIME message
        mimeMsg = createObject("java", "javax.mail.internet.MimeMessage").init(mailSession);
        // create the to and from e-mail addresses
        addrFrom = createObject("java", "javax.mail.internet.InternetAddress").init(vSentFrom);
        for (cfIdx = 1; cfIdx LTE arrayLen( recipientsTo ); cfIdx++)
            addrTo[cfIdx] = createObject("Java", "javax.mail.internet.InternetAddress").init( recipientsTo[cfIdx] );
            // add a recipient
            mimeMsg.addRecipient(recipientType.TO, addrTo[cfIdx]);
        if(ArrayLen(recipientsCC)){
            for (cfIdx = 1; cfIdx LTE arrayLen( recipientsCC ); cfIdx++)
                addrCC[cfIdx] = createObject("Java", "javax.mail.internet.InternetAddress").init( recipientsCC[cfIdx] );
                // add a recipient
                mimeMsg.addRecipient(recipientType.CC, addrCC[cfIdx]);
        if(ArrayLen(recipientsBCC)){
            for (cfIdx = 1; cfIdx LTE arrayLen( recipientsBCC ); cfIdx++)
                addrBCC[cfIdx] = createObject("Java", "javax.mail.internet.InternetAddress").init( recipientsBCC[cfIdx] );
                // add a recipient
                mimeMsg.addRecipient(recipientType.BCC, addrBCC[cfIdx]);
        // build message
        // set who the message is from
        mimeMsg.setFrom(addrFrom);
        // set the subject of the message
        mimeMsg.setSubject(vSubjectText);
        // create multipart message: only needed if you're including both plain/text and html
        // or using attachments
        multipart = createObject("java", "javax.mail.internet.MimeMultipart").init();
        // specifies that the message contains both inline text and html, this is so that
        // images given a cid will show up when rendered by the e-mail client
        multipart.setSubType("mixed");
        // create html text multipart
        oHtml = createObject("java", "javax.mail.internet.MimeBodyPart").init();
        // add the html content (the setText() method shortcut/only works for "plain/text")
        oHtml.setContent( emailContentHTML, "text/html");
        // add the body part to the message
        multipart.addBodyPart(oHtml);
        // loop over files to attach to the email
        for ( intRow = 1 ; intRow LTE qFiles.RecordCount ; intRow = (intRow + 1))
        // set file info to vars
        fileContent = qFiles["fileContent"][intRow];
        fileMimeType = qFiles["mimeType"][intRow];
        fileName = rereplace( qFiles["filename"][intRow] , '(?!\.[^.]*$)\W' , '' , 'all' );
        if(len(fileName) > 50)
        {fileName = mid(fileName,1,44) & right(fileName,find('.',reverse(fileName)));}
        // attach an inline binary object
        att = createObject("java", "javax.mail.internet.MimeBodyPart").init();
        // create an octet stream out of the binary file
        os = createObject("java", "org.apache.axis.attachments.OctetStream").init(fileContent);
        // we now convert the octet stream into the required data source. using an octet stream
        // allows us pass in any binary data as a file attachment
        osds = createObject("java", "org.apache.axis.attachments.OctetStreamDataSource").init("", os);
        // initialize the data handler using the data source
        dh = createObject("java", "javax.activation.DataHandler").init(osds);
        // pass in the binary object to the message--javamail will handle the encoding
        // based on the headers
        att.setDataHandler(dh);
        // define this binary object as a PDF
        att.setHeader("Content-Type", fileMimeType);
        // make sure the binary data gets converted to base64 for delivery
        att.setHeader("Content-Transfer-Encoding", "base64");
        // specify the binary object as an attachment
        att.setHeader("Content-Disposition", "attachment");
        // define the name of the file--this is what the filename will be in the e-mail client
        att.setFileName(fileName);
        // add the body part to the message
        multipart.addBodyPart(att);
        //end loop through qFiles
        // place all the multi-part sections into the body of the message
        mimeMsg.setContent(multipart);
        // in this section we'll build the message into a string. you could dump
        // the string to a file in most SMTP server's queue file for delivery
        // this is exactly what would be pass to the SMTP server
        // create a bytearray for output
        outStream = createObject("java", "java.io.ByteArrayOutputStream");
        // create a budder for the output stream
        outStream.write(repeatString(" ", 1024).getBytes());
        // save the contents of the message to the output stream
        mimeMsg.writeTo(outStream);
        // save the contents of the message to the sMailMsg variable
        sMailMsg = outStream.toString();
        // reset the output stream (for stability)
        outStream.reset();
        // close the output stream
        outStream.close();
        // create a transport to actually send the message via SMTP
        transport = mailSession.getTransport("smtp");
        // connect to the SMTP server using the parameters supplied; use
        // a blank username and password if authentication is not needed
        transport.connect(emailServer, emailServerAccount, emailServerPwd);
        // send the message to all recipients
        transport.sendMessage(mimeMsg, mimeMsg.getAllRecipients());
        // close the transport
        transport.close();
        </cfscript>

  • Query output into cfmail

    I need to send an individual email to about 100 names fetched
    from an Access 2003 database. I am fetching the distinct emails
    from the database and getting each Project owned by each distinct
    email address.
    I created the correct output on a test web page where the
    query will list every distinct email address with each email
    address having their own Project Title listing. Now the question is
    how do I use my output to send an individual email to each of the
    distinct email addresses I got in my query??
    For example someone with the email Address of
    [email protected] would get one email with his Project Title
    listings that could be 3 or 4 titles. The next distinct email
    address of [email protected] will get his own email with his
    Project title listings.
    Here is my attempt but the #userEmail# has everyones email
    address.
    <cfoutput query = "theQuery" group = "userEmail">
    <cfmail to: #userEmail# subject: Project Listing
    <cfoutput>Project Listing:
    #ProjectTitle#</cfoutput>
    <cfmail>
    </cfoutput>
    Please help.

    Jazzy has the correct answer. And if your project listings
    reside in seperate tables, you need to run a seperate query within
    the loop BUT outside of the cfmail in order to retrieve those. So
    that would then be...
    <cfquery name="rs_read" datasource="xxx" >
    SELECT *
    FROM #session.sometable#
    WHERE whateverid = '#variables.whateverid#';
    </cfquery>
    <cfloop index="loopcount" from="1"
    to='#rs_read.RecordCount#' step="1">
    <cfquery name="rs_projects" datasource="xxx" >
    SELECT projects
    FROM #session.sometable#
    WHERE email = '#rs_read.email#';
    </cfquery>
    <cfset variables.proj = ''>
    <cfoutput query="rs_projects">
    <cfset variables.proj = variables.proj & ' ' &
    rs_projects.projects>
    </cfoutput>
    <cfmail from="[email protected]" to="#rs_read.email#"
    subject="#rs_projects.whatever#">
    bla bla #rs_read.anyvariable#
    PROJECTS: #variables.proj#
    </cfmail>
    </cfloop>
    REMEMBER: You can not nest outputs in outputs, that's why you
    can not run the query output inside CFMAIL because CF regards
    cfmail as an output routine.

  • CFMAIL (CF5) sends with many corrupted characters

    I'm maintaining a system that sends out email mailings. The
    same server hosts some Cf applications that also send out some
    mails every once in a while. It has been working fine for a long
    time. However, in the past few weeks, the server started sending
    out the emails with many corrupted characters in them.
    There is no error in the logfiles or something, but it seems
    like when CF gets too busy sending emails, it starts sending memory
    dumps in the mail or so.
    What happens exactly is this. I send out mailings to about
    10.000 people. It loops over a query that gets these people and
    sends out one mail for every 100 persons with the code:
    <CFMAIL from="#attributes.from#" to="#attributes.to#"
    bcc="#attributes.addresses#" subject="#attributes.subject#"
    type="HTML">
    #mailcontent#
    </CFMAIL>
    the attribute 'addresses' contains a list of a 100 email
    addresses.
    In many cases, this works fine. Only when the server appears
    to be quite busy, it sometimes sends out the mails like the example
    below.
    CF-SERVER-02 ˆo
    ¸o
    èo
    €o
    H€o
    CF-SERVEx€o
    ¨€o
    ؀o
    o
    8o
    ho
    CF-SERVER-02 ˜o
    ȁo
    øo
    (‚o
    X‚o
    CF-SERVER-02 ˆ‚o
    ¸‚o
    è‚o
    ƒo
    Hƒo
    n tcp xƒo
    ¨ƒo
    ؃o
    tcp np „o
    Dƒo
    lpc 4%õ x„o
    ,‹o
    @ ¨Åe 4¹ÿ
    ´u ú
    ‘1 p
    ¸M_ÿÿÿÿ¸M_ì„o
    @ ¨Åe 4¹ÿ
    ´ £ (×¢ß äp
    ¸M_ÿÿÿÿ¸M_ìŠo
    @ ¨Åe 4¹ÿ
    4£ ;×8¡ß T
    p
    ¸M_ÿÿÿÿ¸M_¬„o
    @ ¨Åe 4¹ÿ
    4£ Kׄªß 4 5
    ¸M_ÿÿÿÿ¸M_,…o
    @ ¨Åe 4¹ÿ
    ´‰£
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">
    <HTML>
    </HTML>
    ƒo
    Hƒo
    n tcp xƒo
    ¨ƒo
    ؃o
    tcp np „o
    Dƒo
    lpc 4%õ x„o
    ,‹o
    @ ¨Åe 4¹ÿ
    ´u ú
    ‘1 p
    ¸M_ÿÿÿÿ¸M_ì„o
    @ ¨Åe 4¹ÿ
    ´ £ (×¢ß äp
    ¸M_ÿÿÿÿ¸M_ìŠo
    @ ¨Åe 4¹ÿ
    4£ ;×8¡ß T
    p
    ¸M_ÿÿÿÿ¸M_¬„o
    @ ¨Åe 4¹ÿ
    4£ Kׄªß 4 5
    ¸M_ÿÿÿÿ¸M_,…o
    @ ¨Åe 4¹ÿ
    ´‰£
    The code between the HTML tags is exactly as it should be ,
    only mailclients don't understand this anymore and show the
    complete HTML code as a text message.
    This happens when I send out HTML mails, but when sending
    text-emails, the very same happens sometimes.
    It's running on CF5 on win2k.
    I really hope that somebody can help me out!

    In iTunes, select your Music Library (the first entry at the top left in the side bar)
    Press cmd & A keys (Select All)
    In the menu bar, go to Advanced > Convert ID3 tags. Click on "None" to reveal the choices available and choose version 2.4, then on click OK.
    Note: this will not repair damaged accented characters on songs you have already played since updating to iTunes 7.7. You should correct these before updating the tags.

  • CFMAIL sending duplicate messages

    I am using ColdFusion 11 on a Windows Virtual Server 2008.  The CFMAIL tag is producing duplicate messages (3 each time with IE11 and 2 each time with FireFox.  Numerous tests have produced the same results.  I tested with and without the mail spooler enabled - no change.  The code is simple. no loops, no query, no double-click of the 'send' button.  I have seen other complaints about this in other forums with the only solution being "to disable CF scripts that start/stop the mail spooler".  1) Does anyone have a suggestion?  2) How would I disable the CF Script to start/stop the spooler?  Robert

    RM, not your answer, but note that you’ve asked this on the CFBuilder forums. That’s the CF IDE (integrated development environment, or editor).
    You will want to ask this on the CF Forum or one of its subforums instead (perhaps the ColdFusion Server Administration one). It and they are listed at https://forums.adobe.com/community/coldfusion.
    /charlie

  • CFMail to goup by form field code numbers

    Greetings
    I have a situation where a user fills out a form with 1 to 10
    code numbers (Commercial Commodity Codes), which triggers a CFMAIL
    to all Vendors with those codes.
    Would a CFQUERY that had:
    SELECT cccategory_ID, ccc_cat_num
    FROM cccodes_categories
    WHERE ccc_cat_num LIKE '%#form.code_01#%'
    OR ..... etc. etc.
    be the approach here?
    I would need to:
    <cfmail to = "[email protected]"
    all the vendors with either 1 or several of the form field
    codes....</cfmail>
    Thanks in advance
    rinorman

    I got this to work- I'm sure there is a simpler way or a
    different way to do it- but...
    <cfquery name="emailData" datasource="mydata">
    SELECT vendor_email, vendor_cccodes
    FROM main
    WHERE vendor_cccodes LIKE '%#form.code_01#%'
    OR vendor_cccodes LIKE '%#form.code_02#%'
    OR vendor_cccodes LIKE '%#form.code_03#%'
    OR vendor_cccodes LIKE '%#form.code_04#%'
    OR vendor_cccodes LIKE '%#form.code_05#%'
    OR vendor_cccodes LIKE '%#form.code_06#%'
    OR vendor_cccodes LIKE '%#form.code_07#%'
    OR vendor_cccodes LIKE '%#form.code_08#%'
    OR vendor_cccodes LIKE '%#form.code_09#%'
    OR vendor_cccodes LIKE '%#form.code_10#%'
    </cfquery>
    <cfloop query="emailData"> <!--- loop thru vendors
    and send one email to each --->
    <cfmail to="#emailData.vendor_email#"
    from="[email protected]"
    subject="Available Bid"
    server = "emailsrv.whatever">#Form.bid_ID# is
    Available</cfmail>
    </cfloop>
    again, the "vendor_cccodes" field, in this example, is a
    comma-delimited list of from 1 to as many as 10 code numbers.

  • Cfmail - outgoing SMTP in bulk?

    Hello,
    We have a few clients who are youth sports leagues and who, a
    few times a year, need to send emails out to 'all parents' - this
    can be 6000-8000 recipients a pop. We have an email manager program
    that generates recipient lists, works with FCKEditor to create the
    email, and then loops over the list and initiates a <cfmail>
    call for each and every recipient.
    This is not usually a problem, even in moderate quantites of
    one or two thosuand. The problems occur when we get two leagues who
    both do this at the same time, or one league who sends out a big
    email and cuts-and-pastes from MS word where the email is 200kb of
    HTML. I know we could stop the latter from happening, but I'd
    rather find a way to (gasp) enable their bad behavior, if at all
    possible.
    Originally, we had an offsite email provider that we used for
    everything. The problem was that it would require CFMAIL to
    authenticate for each and every email sent, adding something on the
    order of 5-8 seconds' delay to each email. This made sending more
    than a few hundred impractical. We switched to using IIS' built-in
    SMTP service right on the same machine as our Coldfusion server,
    and this has served us pretty well; we don't authenticate but we
    only allow connections from our local IP. We still have the same
    basic problem, though, even if it takes more effort to gum up the
    works.
    My question is: does anyone know a reputable provider of
    outgoing, SMTP-only email service that would either not require
    authentication, or would cache authentication based on IP so as not
    to require us to re-authenticate every single time we send an
    email, or else some way around having to send X-thousand individual
    emails that won't trigger spam filters? How have you solved this
    problem?
    Thanks very much!
    SK

    Azadi,
    We deal with volunteer parents and thousands of them every
    year - and they migrate in and out of the program as their children
    do. It is impractical to try and require them to sign up for
    mailing lists, or even to maintain mailing lists with the
    infrastructure we have. We also have users with multiple roles, and
    recipient lists that are only 10-12 people - 'all parents on team A
    in division X' or 'all volunteer referees in division Y' and so on.
    There are dozens and dozens of recipient lists that change up to
    three times a year.
    We have user addresses in a database and are willing to
    entertain any solution that doesn't require our users to do
    anything differently that is within our means.

  • Looping through email addresses. CFTRY/CFCATCH

    I am building an email system that will be looping through a
    list of email addresses in our database and sending mail via
    CFMAIL. Alot of times, the email addresses are bad. i.e.: no
    ".com", a comma in the email address, bad characters etc. How can I
    loop through the email addresses sending them out, but when CFMAIL
    errors out because of a bad address, the loop continues on ignoring
    the bad address. Can I do this with CFTRY/CFCATCH? Will
    CFTRY/CFCATCH halt the process entirely or will it catch it then
    continue on?

    Cold Fusion has an isvalid function you can use to confirm
    that any
    given string is a properly formatted email address. You can
    use this to
    prevent improperly formatted addresses from getting into your
    db in the
    first place.
    If ColdFusion was used to put the email address into the
    database in the
    first place. That is not always true. Some places have more
    the one
    application working with a given database.
    Now using isValid to validate the address before attempting
    to use it in
    a <cfmail...> tag may provide some value, but would
    still be comfortable
    with wrapping the tag with a try catch. I just like to do so
    whenever I
    am playing with other protocols.

  • CFMAIL error when encountering bad address

    Hello
    I have an app running with approx 6,000 signees. I try to ensure their email going in the DB is validated via javascript- but this not totally effective.
    What code could I write in the CFmail tag that would ignore bad emails, send the meassage without errors, and perhaps even list the bad mail addresses?
    Thanks in advance
    Norman B.

    You may have to validate the e-mails one by one. You could loop through the e-mail addresses, and do something like
    <cfloop>
    <cfset isFromEmailValid = isValid("email", fromEmail)>
    <cfset isToEmailValid = isValid("email", toEmail)>
    <cfset isSubjectValid = len(trim(subject))>
    <cfif isFromEmailValid and isToEmailValid and isSubjectValid>
        <cfmail from="#fromEmail#" to="#toEmail#" subject="#subject#"></cfmail>
      <cfelse>
        <!--- log details of unsent mail--->
      </cfif>
    </cfloop>
    However, as you can easily guess, this method is unsuitable for large e-mail jobs
    [Edited: my initial response had crossed Adam's on the wire.]

  • Debugging CFMAIL attribute / bad address errors

    We sent out email blasts by querying the database for a list of addresses and have been getting two errors which seems to kill off the loop we use to call CFMAIL:
    "Error","mailWorker-5","11/01/12","10:15:29",,"javax.mail.SendFailedException: Invalid Addresses;   nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 501 5.5.4 Invalid Address "
    and
    "Error","ajp-bio-8012-exec-251","10/29/12","10:16:31",,"Attribute validation error for tag CFMAIL."
    I suspect that both are related to some type of malformed email addresses, but how would i determine which email address? is there a way to determine which attribute caused an error?

    ggantzer2 wrote:
    ... have been getting two errors which seems to kill off the loop we use to call CFMAIL
    It's a shame if one error should kill off the loop. Imagine the error occurring after just 3 sent mails out of a 5000-message job! If throughput is important, then you might want to redesign as follows:
    <cfloop query>
    <cftry>
    <cfmail>
    </cfmail>
    <cfcatch type="any">
    <!--- handle errors, for example, log e-mail address and error message --->
    </cfcatch>
    </cftry>
    </cfloop>

Maybe you are looking for

  • QT Pro -- Did I miss something in the documentation?

    Someone please check me on this, because I think I must be getting senile. After many years of thinking about it, I finally popped the whopping $30 for Quicktime Pro (for QTP7 on my 27" iMac Core 2 Duo, OS X 10.6.7). It installed without problem -- t

  • How do you make an object, whose name is equal to a String?

    Ok, heres my situation, I have a vector full of strings which i've enumerated.. and i need to create a bunch of JCheckBox's whose names are equal to the strings in the Enumeration.. I tried going:           Enumeration Type = TypeList.elements();    

  • Can anyone reproduce this bug?

    Mac OS X 10.4.11, with an active Microsoft Remote Desktop Connection and some other windows open, the mouse-pointer disappaers when it is placed on the RDC Window and the Exposé feature "Desktop" is used...

  • Nano software update

    A new Nano was synced and registered, working fine. The second day we hooked up to add more music and a dialog box advised there was an update available. The update would not complete, and reset would not complete, giving error codes indicating hardw

  • How to print a single spread in Print Booklet

    Just got ID CS3 - Have a 20 pg booklet from old version, opened fine, but can't make it print a single spread... tell it to print all, and the pages line up OK in Preview - but when I try and print a single spread, 6-15 for instance, only page 6 show