Creating a Newsletter system

Page 3 of 3
  1. Introduction
  2. Registration
  3. Sending the newsletter

Sending the newsletter

Finally, we need to create a page to send newsletter:

SendNewsletter.cfm

<CFIF IsDefined("Message")>

<CFQUERY NAME="GetMembers" DATASOURCE="Your DSN">
Select *
From Newsletter
<CFIF Form.EmailType EQ "1">
WHERE EmailType = 1
<CFELSE>
WHERE EmailType = 0
</CFIF>
Order By MemberID
</CFQUERY>


<CFLOOP QUERY="GetMembers">
<!--- Determine if email going out will be in HTML format or not --->
<CFIF #Form.EmailType# EQ "1">
<CFMAIL To="#GetMembers.Email#"
From="[email protected]"
Subject="This Week's Newsletter!">
#GetMembers.Message#
Sent: #DateFormat(Now(), 'ddd. mmmm dd, yyyy')#
to Unsubcribe visit: http://www.menofvisionent.com/unsubscribe.cfm
</CFMAIL>
<CFELSE>
<CFMAIL To="#GetMembers.Email#"
From="[email protected]"
Subject="This Week's Newsletter!"
type="HTML">
#GetMembers.Message#
Sent: #DateFormat(Now(), 'ddd. mmmm dd, yyyy')#
to Unsubcribe visit: http://www.menofvisionent.com/unsubscribe.cfm
</CFMAIL>
</CFIF>
</CFLOOP>


<CFELSE>
<form action="sendnewsletter.cfm" method="post">
The Message: <Textarea Name="Message"></textarea><BR>
Send as:
Text <input type="Radio" name="EmailType" value="1">
HTML <input type="Radio" name="EmailType" value="0"><br>
<input type="Submit" Value="Mail Newsletter">
</FORM>
</CFIF>

That's it! You've now created a fully interactive newsletter system for your site!

You might also like...

Comments

About the author

Pablo Varando United States

I've been around computers ever since I could remember, The first time I toyed around with a computer, I was about 3 years old. I ran my own BBS service in Miami from age 7 to 13 and I found it ...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.” - Jon Ribbens