<cfmail to = "recipient" subject = "message subject" from = "sender" more attributes... > <cfmailparam contentID = "content ID" disposition = "disposition type"> file = "file path" filename = "name of the file to be sent as attachment" type ="media type" OR <cfmailparam name = "header name" value = "header value"> ... </cfmail>
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
ColdFusion (2016 release) Update 4: Added the attribute decode.
ColdFusion 8.0.1: Added the attributes Content and Remove.
ColdFusion MX 6.x: Added the Disposition and ContentID attributes.
ColdFusion MX 6.1: Added the type attribute.
This tag attaches a file or adds a header to an e-mail message. It can only be used in the cfmail tag. You can use multiple cfmailparam tags within a cfmail tag. You can use this tag to include a file, such as an image, in an HTML mail message. The file can be displayed inline in an HTML message, or as an attachment, as Example 2 shows. To include multiple files, use multiple cfmailparam tags.
- Specify type="html" in the cfmail tag.
- Specify disposition="inline" and a ContentID attribute in the cfmailparam tag.
- Use a src="cid:ContentIDValue" attribute to identify the content to include in the HTML tag such as the img tag.
Example 1: This view-only example uses the cfmailparamtag to add a header to a message, attach files, and to return a receipt to the sender.
<cfmail from = "firstname.lastname@example.org" To = "email@example.com" Subject = "See Important Attachments and Reply"> <cfmailparam name = "Importance" value = "High"> Please review the new logo. Tell us what you think. <cfmailparam file = "c:\work\readme123.txt" type="text/plain"> <cfmailparam file = "c:\work\logo15Jan.gif" type="image/gif"> <cfmailparam filename = "readme.txt"> <cfmailparam filename = "logo.gif"> <cfmailparam name="Disposition-Notification-To" value="firstname.lastname@example.org"> </cfmail>
<cfmail type="HTML" to = "#form.mailto#" from = "#form.mailFrom#" subject = "Sample inline image"> <cfmailparam file="C:\Inetpub\wwwroot\web.gif" disposition="inline" contentID="image1"> <p>There should be an image here</p> <img src="cid:image1"> <p>After the picture</p> </cfmail>
<cfmail to="email@example.com" from="firstname.lastname@example.org" subject="Filename with valid html entities"> <cfmailparam file="#expandPath(".")#/test%7c.txt" decode="false"> </cfmail>