CSS + CFMail

A came across the dumb little trick a while back, and wanted to share this.

I like to make the mail sent from an application look like it’s part of the application, but often the step is overlooked during the development process. However by using <cfinclude> and CSS, this can be accomplished:

<cfmail to=”user@example.com” subject=”Yo!” type=”HTML” from=”anotheruser@example.com”>

<style type=”text/css”>
<cfinclude template=”[path to CSS for site]”>
[content goes here.]

Granted, you have to make sure that your CSS not huge, or this becomes inefficient.

One thought on “CSS + CFMail

  1. The include is nice a neat way of doing this, especially if your generated newsletter email is long and complex. Wrapping a <savecontent/> around the email content can also be an alternative. Then below it you would just output the ‘savecontent’ variable between cfmail tags.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s