It used to be in pre-ColdFusion MX 7 (CFMX 7), to embed images in an email, to set them up so that they do not show up as attachments or external source links, I needed to use a special CFMail custom tag. Just the other day, on the House of Fusion mailing list, there was a thread about embedding images in emails.
I did not know this, but apparently in ColdFusion MX 7, the CFMailParam tag can be used to embed images directly into the email content. After some initial testing, it seems this is completely true and very exciting! It is almost too easy.
I tried it with two different methodologies. One, embeds a file from the local file system. The other embeds an image from a live Url. Both seemed to work find with Microsoft Outlook and GMail. The live Url link did not work in Hotmail, but was available as a downloadable attachment. While I could not test it, I was told that the test for live Url embedding did not work in Thunderbird.
Here is the sample code:
<cfmail to="firstname.lastname@example.org" from="email@example.com" subject="Embedded Image test via CFMail" type="html"> <h2> This Email is Designed to Test Embedded Email Messages </h2> <p> Image of a puppy I found </p> <p> <img src="cid:puppy" width="350" height="263" alt="" /><br /> </p> <p> Image of two puppies I found </p> <p> <img src="cid:puppies" width="350" height="261" alt="" /><br /> </p> <!--- Embed image via the local file system. ---> <cfmailparam file="#ExpandPath('./puppy.jpg')#" contentid="puppy" disposition="inline" /> <!--- Embed the image via a live Url link. ---> <cfmailparam file="http://some-made-up-domain.com/1119eaf0.jpg?v=0" contentid="puppies" disposition="inline" /> </cfmail>
Want to use code from this post? Check out the license.