CFMail Adding multiple attachments with CFMAILPARAM

In building a project for work I needed to add potentially multiple attachments to an email. Fortunately, CFMail has a way to add header and additional information.

<cfmail to="somebody@domain.com"
from = "yourstruly@domain.com"
subject="something"
server="yourmailserver">
<p>Here are your attachments.</p>
<cfmailparam file="c://yourpath/filename.ext">
</cfmail>

In coldfusion 8+ you can specify whether the file is an attacment or is displayed inline in the message with disposition=”inline” or “attchment”. You can also give the file a name with contentID=”image1″.

If you need to add cc’s or other head information you use Name instead of File for the cfmail param. ie name=”cc” value=”bob@hisdomain.com”

You can pass the values from queries to make the file-name or name-values dynamic. You must use cfloop query=”queryname” rather than cfoutput query=”queryname”. You can use query references like #queryname.fieldname# if there is only 1 value. If you try to use cfoutput query=queryname you will get an odd message telling you that you can not use nested cfoutput.

Cup size   
Select size then click on coffee cup.
This entry was posted in Code, Coldfusion, Problems & Fixes, Snippets. Bookmark the permalink.