ActivMail - Version 2.1.0.3
ActivMail Examples
Send An Email
Send a personalized email using a database
The next example selects email addresses from a query, and dynamically makes the TO list using CF's ValueList() function. This example will also send a multi-part message, because both TEXTMESSAGE and HTMLMESSAGE is specified. This will also generate a verbose logfile with the date in the filename.
<cfquery name="qry" datasource="ds">
SELECT email, name
FROM farmers
</cfquery>
<CF_MAIL
QUERY="qry"
FROM="Billy Jones <[email protected]>"
TO="email"
SUBJECT="Hey %name% I got a new cow"
VERBOSE="1"
TOKENS="1"
TYPE="HTML"
TEXTMESSAGE="Hi %name%, just wanted to announce that I've got a new cow.">
Hi %name%, just wanted to announce that <b>I've got a new cow</b>.
</CF_MAIL>
The following QUERY could be used to generate an address that looks like First Last <[email protected]> with fields in a database named FirstName, LastName, and Email. Using this format recipients will see their name in the TO box of the message, instead of just the email address.
<cfquery name="qry" datasource="ds">
SET CONCAT_NULL_YIELDS_NULL OFF
SELECT firstname + ' ' + lastname + ' <' + email + '>' AS Email
FROM users
</cfquery>
Note: SET CONCAT_NULL_YIELDS_NULL OFF is used to prevent SQL Server from making the result of the concatenation NULL if any of the fields are null. If your name, and email address fields do not allow nulls then you may remove that line. If your email address field allows NULL's and you are concatenating with a name, you should add an extra statement to the where clause that removes null addresses (eg WHERE email <> ''). The above example was designed for SQL Server, if you are running other servers check your database server's documentation.
Using SMTP Authentication
Using Multiple SMTP Servers
Sending an attachment
Embeding an image in HTML Email
Sending an alternative message part
Adding a custom header
Setting the message importance
Setting the message Precedence
ActivMail Documentation
Copyright © CFDEV.COM 2004