<HTML>
<HEAD>
  <TITLE>Mailing List</TITLE>
  <!--- Apply simple CSS formatting to <TH> cells --->
  <STYLE>
    TH {background:blue;color:white;
        font-family:sans-serif;font-size:12px;
        text-align:right;padding:5px;}
  </STYLE>
</HEAD>

<!--- Put cursor in FirstName field when page loads --->
<BODY>

<!--- Page Title --->
<H2>Send Message To Mailing List</H2>

<!--- If the user is submitting the form... --->
<CFIF IsDefined("FORM.Subject")>
  <!--- Retrieve "mailing list" records from database --->
  <CFQUERY DATASOURCE="#REQUEST.DataSource#" NAME="GetList">
    SELECT FirstName, LastName, EMail 
    FROM Contacts
    WHERE MailingList = 1
  </CFQUERY>

  <!--- Send the mail message, based on form input --->
  <CFMAIL
    QUERY="GetList"
    SUBJECT="#Form.Subject#"
    FROM="""Orange Whip Studios"" <mailings@orangewhipstudios.com>"
    TO="""#FirstName# #LastName#"" <#EMail#>"
    BCC="personneldirector@orangewhipstudios.com"
>#FORM.MessageBody#

----------------------------------------------------
We respect your privacy here at Orange Whip Studios.
To be removed from this mailing list, reply to this
message with the word "Remove" in the subject line.
----------------------------------------------------
</CFMAIL>
  
  <!--- Display "success" message to user --->
  <P>The email message was sent.<BR>
  By the way, you look fabulous today. 
  You should be in pictures!<BR>

<!--- Otherwise, display the form to user... --->  
<CFELSE>
  <!--- Provide simple form for recipient and message --->
  <CFFORM ACTION="#CGI.SCRIPT_NAME#" NAME="mailForm" METHOD="POST"
    onSubmit="return confirm('Are you sure? This message will be sent to everyone on the mailing list.  This is your last chance to cancel the bulk mailing.')">
    
    <TABLE CELLPADDING="2" CELLSPACING="2">
      <!--- Table row: Input for E-mail Subject --->
      <TR>
        <TH>Subject:</TH>
        <TD>
          <CFINPUT 
            TYPE="Text" 
            NAME="Subject"
            REQUIRED="Yes"
            SIZE="40"
            MESSAGE="You must provide a subject for the e-mail.">
        </TD>
       </TR>

      <!--- Table row: Input for actual Message Text --->
      <TR>
        <TH>Your Message:</TH>
        <TD>
          <TEXTAREA
            NAME="MessageBody"
            COLS="30"
            ROWS="5"></TEXTAREA>
           
        </TD>
      </TR>

      <!--- Table row: Submit button to send message --->
      <TR>
        <TD></TD>
        <TD>
          <INPUT
            TYPE="Submit"
            VALUE="Send Message Now">
        </TD>
      </TR>
    </TABLE>
  </CFFORM>
</CFIF>  

</BODY>
</HTML>
