0
votes

I am trying this on CF 8.0.1, but failing. I am trying to pass a custom value to the custom tag, like this:

<cf_call ckmail="#{to='[email protected]',from='[email protected]',subject='Error reported',mailserver='mail.domain.com',username='1234',password='tested'}#">

In the custom tag call.cfm i have the following:

<cfparam name="attributes.ckmail" default="">
<cfmail attributecollection = "#attributes.ckmail#">

The error I am getting is:

Invalid CFML construct found on line 11 at column 18. ColdFusion was looking at the following text: {

It is working good in CF9, but in CF8.0.1 (or previous version) it is failing with the above message.


Code Update as of July 18th 2012


I tried using dan's Code but now i am facing a different issue, In my Custom Tag i am using like this

       <cfset emailSetting = StructNew()>
   <!--- loop our query string values and set them in our structure --->
   <cfloop list="#attributes.ckmail#" index="key" delimiters=",">
     <cfset emailSetting["#listFirst(key,'=')#"] = urlDecode(listLast(key,"="))>
   </cfloop>
   <cfdump var="#emailSetting#"><cfabort>
       <cfmail attributecollection = "#emailSetting#"> 

The above are my settings in the custom tag, i called it from my code as

       <cf_call ckmail="[email protected],[email protected],subject='Error reported',
    server=mail.domain.com,[email protected],password=tes@,type=html">

The error now i am getting is "smtp" server is not defined,

if i add smtp details in cfadmin it works, may be it ignores values in the field i typed but it shows error when there is no smtp settings defined in the cfadmin too.

3

3 Answers

2
votes

The implicit structure should work in CF8.0.1 as you have it.

You can of course use code like the following to build your structure using the structNew() function:

<cfset mailArgs             = StructNew() />
<cfset mailArgs.to          = '[email protected]' />
<cfset mailArgs.from        = '[email protected]' />
<cfset mailArgs.subject     = 'Error reported' />
<cfset mailArgs.mailserver  = 'mail.domain.com' />
<cfset mailArgs.username    = '1234' />
<cfset mailArgs.password    = 'tested' />

<cf_call ckmail="#mailArgs#"> 

Can you post a more detailed error report from ColdFusion here so that we can help you find the exact location of the error? Or can you post more of the code?

0
votes

You're using the struct literal syntax in the ckmail attribute, which I think has changed behaviour between CF8 and CF9. I'd try creating a struct the old-fashioned way and see if that works.

0
votes

Hmmm.... I wonder if the pound signs look odd to anyone else in the custom tag call? Stucture notation usually looks like this:

<cfset mystruct = {to='[email protected]',from='[email protected]',subject='Error reported',mailserver='mail.domain.com',username='1234',password='tested'}/>

The pound signs would cause CF to try and "do something" to merge the values (like when you do <cfset z = #x+y#/> ... but leaving them off allows CF to "see" the constructor indicators (the curly braces).

But I'm not sure how a custom tag would behave in that instance. Have you tried calling it like so:

<cf_call 
 ckmail={to='[email protected]',from='[email protected]',subject='Error reported',mailserver='mail.domain.com',username='1234',password='tested'}/>

Or failing that - as has been suggested - set it up ahead of time as:

<cfset args = {to='[email protected]',from='[email protected]',subject='Error reported',mailserver='mail.domain.com',username='1234',password='tested'}/>

Then call:

<cf_call ckmail="#args#"/>

See if any of those work eh?