1

I encountered an AMPscript syntax error and the system implied me something didn't relate to the error. I wonder if there was another way to debug in MC.

Marketing Cloud - Email content debugging

%%[
    var @greeting
    set @greeting = ""
    set @greeting = Concat(@greeting, "Just wanted to say ", Char(34), "Hello", Char(34), " ")
    set @greeting = Concat(@greeting, "and tell you we", Char(39), "re b", Char(97,4), "ck!")

    var @f_name, @l_name
    set @f_name = AttributeValue("FirstName")
    set @l_name = AttributeValue("LastName")

    var @random_str, @first_w
    set @random_str = "Hello my name is Duc"
    if IndexOf(@random_str, " ") > 0 then
        set @first_w = Substring(@random_str, 1, Subtract(Indexof(@random_str, " "), 1))
    endif

]%%

%%[
    var @terms, @termsBlurb, @len, @max
    set @max = 105
    set @terms = "" /* or a literal value */
    set @terms = concat(@terms, "The Rewards program is intended for personal use only. ")
    set @terms = concat(@terms, "Commercial use is prohibited. This program is not targeted towards, ")
    set @terms = concat(@terms, "nor intended for use by, anyone under the age of 13. ")
    set @terms = concat(@terms, "If you are between the ages of 13 and 18, you may only use Rewards ")
    set @terms = concat(@terms, "under the supervision of a parent or legal guardian who agrees to ")
    set @terms = concat(@terms, "be bound by these Terms of Use.")

    set @termsBlurb = @terms
    set @len = Length(@terms)
    if @len > @max then
        set @termsBlurb = concat(Trim(substring(@term, 1, @max),) "...") /* syntax error here */
    endif
]%%

Hi %%=v(concat(@f_name, " ", @l_name))=%%
<br>greeting: %%=v(@greeting)=%%
<br>%%=v(@first_w)=%%
<br><br>terms: %%=v(@terms)=%%
<br>len: %%=v(@len)=%%
<br>termsBlurb: %%=v(@termsBlurb)=%%

In the 2nd AMPscript block, there was a syntax error and in somehow the system didn't show me the error but the announcement like the first picture.

P/s: I used VScode for coding AMPscript (AMPscript v1.4.3 extension for syntax highlighting) and it didn't show up the syntax error too. So I had to manually review the code and fixed it.

1
  • The message relates to the absence of required CAN-SPAM personalization strings in your message, rather than a syntax error. If you place the standard CAN-SPAM strings in your email, does the error message disappear? help.salesforce.com/…
    – Macca
    Commented Jul 6, 2020 at 4:50

1 Answer 1

1

Every Promotional email sent from any ESP [Email Sending Platform] must comply with CAN-SPAM Act

As per the requirements of this ACT, SFMC has mandated to implement these in you Emails. Hence, you are getting the above error! And it is nothing to do with your AMPscript code!

To resolve,

Option 01: Custom Footer

If you wish to implement custom footer which includes,

  • Custom Unsub page
  • Custom Preference Center page
  • Your Company's Physical address Then you can raise a support Case and request them to turn-off this feature.

Option 02: Use Default footer

The platform has provided all the above features built-in and you just make sure your email have them.

You need to include
Profile Center Link and
Physical Mailing Address
as you can see in your message; to resolve your error.

Please make use the built in Code Snippets as below to resolve your errors. enter image description here

Option 03: [suggested by Johannes Schapdick]

Include the below snippet in the mail and make it never get processed.

%%[ if 0 == 1 then ]%%
    %%Member_Busname%% %%Member_Addr%% %%Member_City%%  
    %%Member_State%% %%Member_PostalCode%% %%Member_Country%%
    %%profile_center_url%% 
%%[ endif ]%% 
6
  • 1
    Or Option 3: %%[ if 0 == 1 then ]%% %%Member_Busname%% %%Member_Addr%% %%Member_City%% %%Member_State%% %%Member_PostalCode%% %%Member_Country%% %%profile_center_url%% %%[ endif ]%% include it in the mail and make it never get processed. Commented Jul 6, 2020 at 6:35
  • @JohannesSchapdick thanks for your additional knowledge! Even I was not aware of this technique!!! .... I will add it to my answer, so evey one can benefit from it. Commented Jul 6, 2020 at 6:37
  • @JohannesSchapdick The option 3 is great. Now it showed me where my syntax error is being made. I will add my code to make my question more clear.
    – Duc Le
    Commented Jul 6, 2020 at 7:10
  • @JohannesSchapdick Can you please explain about the code %%[ if 0 == 1 then ]%% ?
    – Duc Le
    Commented Jul 6, 2020 at 7:20
  • 3
    Be careful with Option 3 though, it can leave you open to risk of breaking CAN-SPAM compliance (among other policies and laws) which can leave you open to lawsuits or fines that can add up quickly - along with a lowered sending reputation. So basically it is a 'Use at your own risk'. Commented Jul 6, 2020 at 12:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .