ColdFusion CFMAIL

Of course, as a programmer we are often face with different challenges every day. The problem faced now is images losing their content when in the CFMAIL. Of course there’s always a solution because ColdFusion always anticipates or adds new tags or components to the language to solve any apparent issue. So, I dedicated constant research to the topic of CFMAIL and how to attach images instead of just linking them. Linking images in CFMAIL has a little side effect. The introduction of CFMAILPARAM enables embedded images in the e-mail, which do not show up as an attachment or an external link.

The following snippet should illustrate how easy it is to embed images into CFML tags.

  • <cfmail
  • to=””
  • from=””
  • subject=”Embedded Image via CFMail”
  • type=”html”>
  • <div>
  • <img src=”cid:girl”/><br />
  • </div>
  • <div>
  • <img src=”cid:test” width=”350″ height=”261″ alt=”" /><br />
  • </div>
  • <!— Embed images. —>
  • <cfmailparam
  • file=””
  • contentid=”test”
  • disposition=”inline”
  • />
  • </cfmail>