Coast Line
asked on
cfmail in custom tag issue
<cf_call email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}">
now in my Custom tag, call.cfm
<cfmail attributecollection="#attr ibutes.ema il#">
i get an error
The attributeCollection attribute in the cfmail tag can only be a structure.
what seems to be wrong, i find nothing
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}">
now in my Custom tag, call.cfm
<cfmail attributecollection="#attr
i get an error
The attributeCollection attribute in the cfmail tag can only be a structure.
what seems to be wrong, i find nothing
ASKER
but from custom tag i am referring the email one, i do have other attributes but that will certainly going to create a problem
ASKER
or either i just pass it as:
<cfmail attributecollection="#emai l#">
:?
<cfmail attributecollection="#emai
:?
attributeCollection requires a structure, usually one of the variable scopes such as FORM, attributes, etc. If you only want to use one value, then you need to remove attributeCollection and specify that value
<cfmail from="#attributes.email#"
.... but then you have to specify all required parameters such as TO, SUBJECT, etc...
This is not valid because #email# is not a collection of values, it is a single value..
<cfmail attributecollection="#emai l#">
<cfmail from="#attributes.email#"
.... but then you have to specify all required parameters such as TO, SUBJECT, etc...
This is not valid because #email# is not a collection of values, it is a single value..
<cfmail attributecollection="#emai
ASKER
there might be some way of passing the info
Let's step back and start from the top because I think we are talking about different things.
When you use your cf_mail custom tag you are passing a bunch of variables to it individually..
<cf_call email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}">
Now, inside your custom tag you are receiving these all as attribute scope variables. You want to pass these to your CFMAIL call, so you would use the attribute collection with the ATTRIBUTES scope.. that will pass along everything you received into your CF_MAIL custom tag...
<cfmail attributecollection="#attr ibutes#">
What is wrong with that?
I recommend doing it differently though. I think inside your CF_MAIL tag you should hard code each attribute. What if someone passed junk to your CF_MAIL custom tag, you don't want to automatically pass that along to your CFMAIL tag it would throw an error.
Pass along all the values from your form submit..
<cf_mail attributeCollection="#form #">
Inside that, call CFMAIL with each one..
<cfmail from="#attributes.from#" to="#attributes.to#" subject="#attributes.subje ct#">
... etc...
That is the way I suggest doing it.. it keep the CFMAIL call clean
When you use your cf_mail custom tag you are passing a bunch of variables to it individually..
<cf_call email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}">
Now, inside your custom tag you are receiving these all as attribute scope variables. You want to pass these to your CFMAIL call, so you would use the attribute collection with the ATTRIBUTES scope.. that will pass along everything you received into your CF_MAIL custom tag...
<cfmail attributecollection="#attr
What is wrong with that?
I recommend doing it differently though. I think inside your CF_MAIL tag you should hard code each attribute. What if someone passed junk to your CF_MAIL custom tag, you don't want to automatically pass that along to your CFMAIL tag it would throw an error.
Pass along all the values from your form submit..
<cf_mail attributeCollection="#form
Inside that, call CFMAIL with each one..
<cfmail from="#attributes.from#" to="#attributes.to#" subject="#attributes.subje
... etc...
That is the way I suggest doing it.. it keep the CFMAIL call clean
ASKER
okay now it is like this
<cf_call email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}"
logfile="yes" attached="yes">
now u see i have other attributes being send to,
why i m trying to use attributes.email is because it should refer to that passed one value
i hope i am clear now
<cf_call email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}"
logfile="yes" attached="yes">
now u see i have other attributes being send to,
why i m trying to use attributes.email is because it should refer to that passed one value
i hope i am clear now
Ok, I see what you are doing... you are creating a structure in the variable EMAIL
I think it should be..
--- create email as a structure of values...
<cfset email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}" >
... pass the structure as a collection
<cf_mail attributeCollect="#email#" logfile="yes" attached="yes">
I think it should be..
--- create email as a structure of values...
<cfset email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}" >
... pass the structure as a collection
<cf_mail attributeCollect="#email#"
ASKER
u are making my custom tag wrong its not
<cf_mail, it is <cf_call mail="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}">
<cf_mail, it is <cf_call mail="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}">
So CF_CALL requires a parameter called "mail" which is a structure?
If true, then I would go back to what you had suggested...
<cfmail attributecollection="#attr ibutes.ema il#">
What happens when you do this?
Sorry, I didn't realize that "email" was a structure of values being passed as a structure to the custom tag
You can do a dump of the variable to make sure it looks good before..
<cfdump var="#attributes.email#">
<cfmail attributecollection="#attr ibutes.ema il#">
If true, then I would go back to what you had suggested...
<cfmail attributecollection="#attr
What happens when you do this?
Sorry, I didn't realize that "email" was a structure of values being passed as a structure to the custom tag
You can do a dump of the variable to make sure it looks good before..
<cfdump var="#attributes.email#">
<cfmail attributecollection="#attr
ASKER
i did dumped, works weel shows good information in dump but when it goes to cfmail tag it breaks
what is the error message?
ASKER
ok, now i got it resolved here it is:
<cf_call email ="#{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}#">
<cfmail attributecollection="#attr ibutes.ema il#">
and it worked, it expects the value to be wrapped with ##, do not why
<cf_call email ="#{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}#">
<cfmail attributecollection="#attr
and it worked, it expects the value to be wrapped with ##, do not why
> and it worked, it expects the value to be wrapped with ##, do not why
It should not have appeared correctly in the dump then..
You were probably seeing all the values in one row of the table cell, each row of the dump should have had one variable and one value
It should not have appeared correctly in the dump then..
You were probably seeing all the values in one row of the table cell, each row of the dump should have had one variable and one value
ASKER
means
well i have still to dump it after i pass it as ##
i have dumped it without hashes and it shows correct order passing it as structure
so now i will dump again as i am now passing it by ## around it and see what does it shows me now and then i will share my findings
well i have still to dump it after i pass it as ##
i have dumped it without hashes and it shows correct order passing it as structure
so now i will dump again as i am now passing it by ## around it and see what does it shows me now and then i will share my findings
ASKER
ok, now is the issue again in CF 8.0.1
I get the following Error
Invalid CFML construct found on line 11 at column 18.
ColdFusion was looking at the following text:
{
The CFML compiler was processing:
while in CF 9, It works Fine
I get the following Error
Invalid CFML construct found on line 11 at column 18.
ColdFusion was looking at the following text:
{
The CFML compiler was processing:
while in CF 9, It works Fine
<cfset email = structNew()>
<cfset email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}" >
--- make sure you have a good, valid structure ----
<cfdump var="#email#">
--- pass the structure
<cf_mail email="#email#" logfile="yes" attached="yes">
perhaps you can include an image of the cfdump result as it shows INSIDE the cf_mail custom tag
<cfset email ="{to='test@test.com',
from='test@test.com',
subject='Error reported',
server='mail.test.com',
username='test@test.com',
password='test'}" >
--- make sure you have a good, valid structure ----
<cfdump var="#email#">
--- pass the structure
<cf_mail email="#email#" logfile="yes" attached="yes">
perhaps you can include an image of the cfdump result as it shows INSIDE the cf_mail custom tag
I forgot to add a note, perhaps the difference between CF 8 and 9 is the ability to do in-line structure definition. You could get around that by creating the structure into a variable first???
(see code above)
(see code above)
ASKER
alright, i have found some code from Dan's Site which is converting the values of the following into this
<cf_call email="to=test@test.com,fr om=test@te st.com,sub ject=Error reported,
server=mail.test.com,usern ame=test@t est.com,pa ssword=tes t,type=htm l" log="yes">
<cfset emailSetting = StructNew()>
<!--- loop our query string values and set them in our structure --->
<cfloop list="#attributes.email#" index="key" delimiters=",">
<cfset emailSetting["#listFirst(k ey,'=')#"] = urlDecode(listLast(key,"=" ))>
</cfloop>
now when i dump it the
<cfdump var="#emailSetting#">, it shows the dump correctly, but when i pass it to the cfmail tag, it says smtp server is not defined
no, i have agreed on ur points than cf9 and cf8 syntaxes differ, but for this tag, i want to use one value so it should be compatible with both, i hope u agree on my points
thanks
<cf_call email="to=test@test.com,fr
server=mail.test.com,usern
<cfset emailSetting = StructNew()>
<!--- loop our query string values and set them in our structure --->
<cfloop list="#attributes.email#" index="key" delimiters=",">
<cfset emailSetting["#listFirst(k
</cfloop>
now when i dump it the
<cfdump var="#emailSetting#">, it shows the dump correctly, but when i pass it to the cfmail tag, it says smtp server is not defined
no, i have agreed on ur points than cf9 and cf8 syntaxes differ, but for this tag, i want to use one value so it should be compatible with both, i hope u agree on my points
thanks
ASKER
any update on this
Oh, I thought your last post was the resolution!
The code you showed is taking a list and parsing it. That shows that you are not passing a STRUCTURE to the custom tag, but you are just passing a list.
Define your structure like this...
<cfset email = structNew()>
<cfset email.to = "">
<cfset email.from = "">
<cfset email.subject = "">
<cfset email.server = "">
<cfset email.username = "">
<cfset email.password = "">
Then pass the email structure to your custom tag
The code you showed is taking a list and parsing it. That shows that you are not passing a STRUCTURE to the custom tag, but you are just passing a list.
Define your structure like this...
<cfset email = structNew()>
<cfset email.to = "">
<cfset email.from = "">
<cfset email.subject = "">
<cfset email.server = "">
<cfset email.username = "">
<cfset email.password = "">
Then pass the email structure to your custom tag
> <cfdump var="#emailSetting#">, it shows the dump correctly, but when i pass it to the cfmail tag, it says smtp server is not defined
OR you can leave the code as you have it now (passing a list and then parsing the list) but when you pass it to the CFMAIL tag you have to use the emailSetting structure
<cfmail attributecollection="#emai lSetting #">
OR you can leave the code as you have it now (passing a list and then parsing the list) but when you pass it to the CFMAIL tag you have to use the emailSetting structure
<cfmail attributecollection="#emai
ASKER
yes after parsing the list and it converts the parsed list into structure, i do the same as you did in ur last post, but it picks everything except the server, says smtp server not defined
ASKER
any update @gd, or we should use a different approach which works on on both servers, CF 8 adn CF9
Can you post the code from the approach you're currently using.
I think this is the way to define your structure before passing it...
<cfset email = structNew()>
<cfset email.to = "">
<cfset email.from = "">
<cfset email.subject = "">
<cfset email.server = "">
<cfset email.username = "">
<cfset email.password = "">
Not sure what you've tried and not. But if you can show your current code, I could play with it a bit..
I think this is the way to define your structure before passing it...
<cfset email = structNew()>
<cfset email.to = "">
<cfset email.from = "">
<cfset email.subject = "">
<cfset email.server = "">
<cfset email.username = "">
<cfset email.password = "">
Not sure what you've tried and not. But if you can show your current code, I could play with it a bit..
ASKER
ok my call is like this:
<cf_ckmail iEmail="to=test@test.com,f rom=test@t est.com,su bject='Err or reported',
server=mail.test.com,usern ame=test@t est.com,pa ssword=tes t,type=htm l"
iLog="yes">
now my custom tag
<cfparam name="attributes.iLog" default="no">
<cfparam name="attributes.iEmail" default="">
<cfif attributes.iEmail NEQ "">
<cfset emailSetting = StructNew()>
<!--- loop our query string values and set them in our structure --->
<cfloop list="#attributes.iEmail#" index="key" delimiters=",">
<cfset emailSetting["#listFirst(k ey,'=')#"] = urlDecode(listLast(key,"=" ))>
</cfloop>
<cfmail attributecollection = "#emailSetting#">
Errors has been reported by the user
<br>
<cfif attributes.iLog EQ "Yes">
The Log File has been created/appended for this Error too
</cfif>
</cfmail>
</cfif>
</cfif>
<cf_ckmail iEmail="to=test@test.com,f
server=mail.test.com,usern
iLog="yes">
now my custom tag
<cfparam name="attributes.iLog" default="no">
<cfparam name="attributes.iEmail" default="">
<cfif attributes.iEmail NEQ "">
<cfset emailSetting = StructNew()>
<!--- loop our query string values and set them in our structure --->
<cfloop list="#attributes.iEmail#"
<cfset emailSetting["#listFirst(k
</cfloop>
<cfmail attributecollection = "#emailSetting#">
Errors has been reported by the user
<br>
<cfif attributes.iLog EQ "Yes">
The Log File has been created/appended for this Error too
</cfif>
</cfmail>
</cfif>
</cfif>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
with real email, it works but only it fails when it goes to the custom tag i wonder why?
ASKER
Hi @gd, Let's Get back to this Question so we can try again, I will share my Whole Code with you so we can come to some kind of Solution
ASKER
Hi @gd, Let's Get back to this Question so we can try again, I will share my Whole Code with you so we can come to some kind of Solution
Another Call for @gd so we can come to any solution and close this question properly rather than an in complete answer
Another Call for @gd so we can come to any solution and close this question properly rather than an in complete answer
ASKER
Should we try or not, or should i delete this question
still working on this? Wow!
Curious - post your code and we'll see what's up
Curious - post your code and we'll see what's up
ASKER
@gd, should i close
ASKER
Accepting the answer as it still does not provide me real answer but to close one what i am trying to do, hopefully i can find answer from somewhere else, for thanks for your help
I think you want...
<cfmail attributecollection="#attr
not
<cfmail attributecollection="#attr