Share this Page URL
Help

Step 7. Using Email with ColdFusion MX > Example 7.1: Creating a Web-Based Emai... - Pg. 152

Using Email with ColdFusion MX 152 In the preceding code, we use <CFSET> to set the value of two local variables: UserName and UserEmail. Then we use the value of the UserEmail variable in our <CFMAIL> tag to set the TO address for the email. The body of the email message uses the value of the UserName variable to personalize the email. Further down the template, we use <CFOUTPUT> and the UserName var- iable to display a confirmation message in the browser. You can see that using ColdFusion variables to create our email messages can be quite a powerful thing. It gives us the capability to create dynamic, personalized, automated email systems to interact with our web site users. The use of variables with <CFMAIL> is not limited to local variables; you can use variables from other scopes, such as URL and FORM. In the section "Advanced <CFMAIL> Attributes" later in this step, we will also see how to use database queries to send bulk email. You can address ColdFusion email to more than one person by placing multiple email ad- dresses in the TO attribute. Multiple email addresses should be separated by a comma, as illustrated in the following code. You can also use the CC and BCC attributes to send carbon copies and blind carbon copies, respectively. <CFMAIL TO="user1@anysite.com,user2@anysite.com" CC="webmaster@anysite.com" BCC="theboss@anysite.com" FROM="automail@learncoldfusionmx.com" SUBJECT="Using CFMAIL" SERVER="smtpserver.myisp.com"> Hello everyone, nice to hear from you! </CFMAIL> NOTE