Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFMAIL and adding CC if needed

LEGEND ,
Aug 03, 2008 Aug 03, 2008
I am currently looping over a list of email addresses and sending out the
mail to all users. I'd like to instead check to see if a variable is set,
and add the cc="" in the cfmail tag instead.

When I try this it fails, I simply did a <cfif MailCC neq
"">cc="name@site.com"</cfif> in the cfmail tag, but it doesn't seem to like
this.

Has anyone done anything similar?

Or how can I get this to work?

Thanks!

1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2008 Aug 03, 2008
i have not tried it, but i know several ways to make it work:

1) put your whole CFMAIL tag inside a cfif block checking for MailCC var
. you will have 2 complete cfmail tags - one executed when MailCC var
exists (this one will have the cc=".." attribute in it), another
(without cc) executed when MailCC var is empty:

<cfif len(trim(MAilCC))>
<cfmail cc="..." ...>
...
</cfmail>
<cfelse>
<cfmail ...><!--- no cc attrib in this one --->
...
</cfmail>
</cfif>

2) use attributeCollection attribute of cfmail tag. assumes you are on
cf8. (or is it only update 1 that allows using attributeCollection
together with in-tag attributes? if so, you have to be on cf8.0.1).

something like:

<cfscript>
mailAttr = {};
mailAttr.server = "mail.somedomain.com";
mailAttr.username = "...";
mailAttr.password = "...";
mailAttr.from = "name@somedomain.com";
mailAttr.subject = "mail subject here";
if (len(trim(MailCC)) gt 0)
mailAttr.cc = "ccname@somedomain.com";
</cfscript>

<cfmail to="..." attributeCollection="#mailAttr#">
...
</cfmail>

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 03, 2008 Aug 03, 2008
quote:

Originally posted by: Newsgroup User
I am currently looping over a list of email addresses and sending out the
mail to all users. I'd like to instead check to see if a variable is set,
and add the cc="" in the cfmail tag instead.

When I try this it fails, I simply did a <cfif MailCC neq
"">cc="name@site.com"</cfif> in the cfmail tag, but it doesn't seem to like
this.

Has anyone done anything similar?

Or how can I get this to work?

Thanks!



You can never put one cf tag inside another like this.

<cftag1 <cftag2> </cftag2> >

To get it to work, my approach would be do the if/else stuff in advance and set a variable to either an empty string or "cc='whoever'". Then put that variable into your cfmail tag.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 03, 2008 Aug 03, 2008
Or else,

<cfmail to="email_id_goes_here" from="from_info_goes_here" subject="subject_goes_here" cc="#Iif(IsDefined('your_cc_variable') and len(your_cc_variable) gt 0,DE(your_cc_variable),DE(''))#">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 04, 2008 Aug 04, 2008
Ok, I tried:
<cfmail from="info@site.com" to="#mail#"
cc="#iif(isdefined("MailCC"),de("MailCC"),de(""))#" subject="Fencing e-mail
regarding #cReason#" type="html" replyto="#form.contactEmail#">

And it still send to the 1st email only, but not the MailCC.... and I am
manually setting that varialbe, so I know it has a value..........

Why isn't it sending to the MailCC??

"Daverms" <webforumsuser@macromedia.com> wrote in message
news:g763qi$egd$1@forums.macromedia.com...
> Or else,
>
> <cfmail to="email_id_goes_here" from="from_info_goes_here"
> subject="subject_goes_here" cc="#Iif(IsDefined('your_cc_variable') and
> len(your_cc_variable) gt 0,DE(your_cc_variable),DE(''))#">
>
>
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 04, 2008 Aug 04, 2008
Hi Steve,

Couple of questions though,

i) Are you setting the MailCC variable somewhere in your page before the <cfmail> declaration. (Try a cfdump)?..

ii) What do you get when assigning
"#Iif(IsDefined('your_cc_variable') and
> len(your_cc_variable) gt 0,DE(your_cc_variable),DE(''))#" to a variable (using cfset) and printing it?...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 05, 2008 Aug 05, 2008

"Daverms" <webforumsuser@macromedia.com> wrote in message
news:g78qnf$iac$1@forums.macromedia.com...
> Hi Steve,
>
> Couple of questions though,
>
> i) Are you setting the MailCC variable somewhere in your page before the
> <cfmail> declaration. (Try a cfdump)?..

Yes, I'm manually setting the MailCC variable before the <cfmail> tag.
>
> ii) What do you get when assigning
> "#Iif(IsDefined('your_cc_variable') and
> > len(your_cc_variable) gt 0,DE(your_cc_variable),DE(''))#" to a variable
> (using cfset) and printing it?...


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 05, 2008 Aug 05, 2008
Hi,

Can you please post your code?.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 11, 2008 Aug 11, 2008
I get the email address that is defined for 'your_cc_variable'

"Daverms" <webforumsuser@macromedia.com> wrote in message
news:g7b0s9$5fk$1@forums.macromedia.com...
> Hi,
>
> What do you get when outputting
>
> "#Iif(IsDefined('your_cc_variable') and
>> len(your_cc_variable) gt 0,DE(your_cc_variable),DE(''))#"

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 12, 2008 Aug 12, 2008
LATEST
Hi,

quote:

I get the email address that is defined for 'your_cc_variable'


Can you please be more specific about your last reply?.. Do you mean the solution that I provided you earlier is working?.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources