{ Akbarsait NoorMohamed }

Using both AttributeCollection and other Attributes with ColdFusion tags in CF 8.0.1

Jul 17, 2008
     #coldfusion  
2 minutes

The ColdFusion 8 AttributeCollection is one of the coolest features with ColdFusion 8 Release. The ColdFusion 8.0.1 release gave some enhancements to AttributeCollection which is nothing but combining both attributes and attributecollection with a ColdFusion tag. We can use attributecollection like this

<!--- Creating attributecollection name/value pairs for cfmail tag --->

<cfset objMailAttributes = {
    Server   = "mail.mycompany.com",
    Username = "companyxyz",
    Password = "zyxcompany",
    To       = "tomail@mycompany.com",
    From     = "frommail@mycompany.com",
    Subject  = "Using AttributeCollection and Attributes in CF8",
    Type     = "plain"

                   } />

<!--- Using attributecollection structure in the cfmail tag --->
<cfmail attributecollection = "#objMailAttributes#" type="html">
    <p>
        Now we can use both AttributeCollection and Attributes with ColdFusion tags in CF 8.0.1
    </p>
</cfmail>

In the above code I have added an attribute type with value “html”. So if an individual attribute is already defined in the attributecollection then ColdFusion will only use the individual attribute value. Executing the above code with CF 8.0.0 will throw you an error like below.

The attributeCollection attribute cannot be used in combination with other attributes in the cfmail tag.

Related Information:

Comment

Chris Bowyer on 2013-03-30
Thanks for this article. You answered my question.

(Comments migrated from previous blog engine.)