0

I created a blank HTML Template using the blank template called: my template under Content Builder folder. I created 4 content blocks with the following:

  • data-key="emailfunction" data-label="Email Function">
  • data-key="emailheader" data-label="Email Header"
  • data-key="emailcontent" data-label="Email Content"
  • data-key="emailfooter" data-label="Email Footer"

I create a template based email from the previously created template called my email under Content Builder and edited the content area's as follows:

Inside the emailfunction content area, i added a code snippet block with the following:

%%[ 
if @number == 10 then 
set @numberEvaluated = "Number equals ten." 
elseif @number > 10 then 
set @numberEvaluated = "Number is greater than ten." 
else 
set @numberEvaluated = "Number is less than ten." 
endif 
]%%

and finally inside the emailcontent area i added the following code snippet:

%%[set @number = 20]%%
%%=ContentAreaByName("my contents\emailfunction")=%% 
%%=v(@numberEvaluated)=%%

All of this was done as per the SFMC documentation found here as well as other stackexchange pages. The content blocks in the template were made by copy pasting the html since i couldn't find a way via the GUI.

The error i get is:

The subscriber preview failed to generate. Review the details, correct all issues, and try again.
An error occurred when attempting to evaluate a ContentAreaByName function call. Function Call: ContentAreaByName("my contents\emailfunction") See inner exception for details.
Content Area "my contents\emailfunction" could not be found. Client ID: XX Function Name: ContentAreaByName Parameter Name: ContentName Parameter Ordinal: 1 Parameter Type: Text Submitted Value: my contents\emailfunction ClientID: XX JobID: 0 ListID: 0 BatchID: 0 SubcriberID: XX Data Source Type: CustomObject Data Source ID: XX

I don't understand what i'm doing wrong, am I creating content area's incorrectly, is there a different meaning than the one in the documentation or am i just providing the wrong path? Thanks guys.

Sample Template: Content Builder\my template

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
      ReadMsgBody{ width: 100%;}
      .ExternalClass {width: 100%;}
      .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;}
      body {-webkit-text-size-adjust:100%; -ms-text-size-adjust:100%;margin:0 !important;}
      p { margin: 1em 0;}
      table td { border-collapse: collapse;}
      img {outline:0;}
      a img {border:none;}
      @-ms-viewport{ width: device-width;}
    </style>
    <style type="text/css">
      @media only screen and (max-width: 480px) {
        .container {width: 100% !important;}
        .footer { width:auto !important; margin-left:0; }
        .mobile-hidden { display:none !important; }
        .logo { display:block !important; padding:0 !important; }
        img { max-width:100% !important; height:auto !important; max-height:auto !important;}
        .header img{max-width:100% !important;height:auto !important; max-height:auto !important;}
        .photo img { width:100% !important; max-width:100% !important; height:auto !important;}
        .drop { display:block !important; width: 100% !important; float:left; clear:both;}
        .footerlogo { display:block !important; width: 100% !important; padding-top:15px; float:left; clear:both;}
        .nav4, .nav5, .nav6 { display: none !important; }
        .tableBlock {width:100% !important;}
        .responsive-td {width:100% !important; display:block !important; padding:0 !important; }
        .fluid, .fluid-centered {
          width: 100% !important;
          max-width: 100% !important;
          height: auto !important;
          margin-left: auto !important;
          margin-right: auto !important;
        }
        .fluid-centered {
          margin-left: auto !important;
          margin-right: auto !important;
        }
        /* MOBILE GLOBAL STYLES - DO NOT CHANGE */
        body { padding: 0px !important; font-size: 16px !important; line-height: 150% !important;}
        h1 { font-size: 22px !important; line-height: normal !important;}
        h2 { font-size: 20px !important; line-height: normal !important;}
        h3 { font-size: 18px !important; line-height: normal !important;}
        .buttonstyles {
          font-family:arial,helvetica,sans-serif !important;
          font-size: 16px !important;
          color: #FFFFFF !important;
          padding: 10px !important;
        }
        /* END OF MOBILE GLOBAL STYLES - DO NOT CHANGE */
      }
      @media only screen and (max-width: 640px) {
        .container { width:100% !important; }
        .mobile-hidden { display:none !important; }
        .logo { display:block !important; padding:0 !important; }
        .photo img { width:100% !important; height:auto !important;}
        .nav5, .nav6 { display: none !important;}
        .fluid, .fluid-centered {
          width: 100% !important;
          max-width: 100% !important;
          height: auto !important;
          margin-left: auto !important;
          margin-right: auto !important;
        }
        .fluid-centered {
          margin-left: auto !important;
          margin-right: auto !important;
        }
      }
    </style>
    <!--[if mso]>
      <style type="text/css">
          /* Begin Outlook Font Fix */
          body, table, td {
              font-family: Arial, Helvetica, sans-serif ;
              font-size:16px;
              color:#000000;
              line-height:1;
          }
          /* End Outlook Font Fix */
      </style>
    <![endif]-->
  </head>
  <body bgcolor="#ffffff" text="#000000" style="background-color: #ffffff; color: #000000; padding: 0px; -webkit-text-size-adjust:none; font-size: 16px; font-family:arial,helvetica,sans-serif;">
    <div style="font-size:0; line-height:0;"><custom name="opencounter" type="tracking"><custom name="usermatch" type="tracking" /></div>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
      <tr>
        <td align="center" valign="top">
          <custom type="header"/>
        </td>
      </tr>
      <tr>
        <td align="center">
          <table cellspacing="0" cellpadding="0" border="0" width="600" class="container" align="center">
            <tr>
              <td>
                <table class="tb_properties border_style" style="background-color:#FFFFFF;" cellspacing="0" cellpadding="0" bgcolor="#ffffff" width="100%">
                  <tr>
                    <td align="center" valign="top">
                      <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                          <!-- added padding here -->
                          <td class="content_padding" style="">
                            <!-- end of comment -->
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">

                              <tr> <!-- AMP Script Function -->
                                <td align="center" class="header" valign="top">
                                  <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                        <tr>
                                          <td align="left" valign="top">
                                            <table cellspacing="0" cellpadding="0" style="width:100%">
                                              <tbody>
                                              <tr>
                                                <td class="responsive-td" valign="top" style="width: 100%;">
                                                  <div data-type="slot" data-key="emailfunction" data-label="Email Function">
                                                  </div>
                                                </td>
                                              </tr>
                                              </tbody>
                                            </table>
                                          </td>
                                        </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>

                              <tr> <!-- top slot / header -->
                                <td align="center" class="header" valign="top">
                                  <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                        <tr>
                                          <td align="left" valign="top">
                                            <table cellspacing="0" cellpadding="0" style="width:100%">
                                              <tbody>
                                              <tr>
                                                <td class="responsive-td" valign="top" style="width: 100%;">
                                                  <div data-type="slot" data-key="emailheader" data-label="Email Header">
                                                  </div>
                                                </td>
                                              </tr>
                                              </tbody>
                                            </table>
                                          </td>
                                        </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>

                              <tr> <!-- middle slot / content -->
                                <td align="center" class="header" valign="top">
                                  <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                        <tr>
                                          <td align="left" valign="top">
                                            <table cellspacing="0" cellpadding="0" style="width:100%">
                                              <tbody>
                                              <tr>
                                                <td class="responsive-td" valign="top" style="width: 100%;">
                                                  <div data-type="slot" data-key="emailcontent" data-label="Email Content">
                                                  </div>
                                                </td>
                                              </tr>
                                              </tbody>
                                            </table>
                                          </td>
                                        </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>

                              <tr> <!-- bottom slot / footer -->
                                <td align="center" class="header" valign="top">
                                  <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
                                    <tbody>
                                        <tr>
                                          <td align="left" valign="top">
                                            <table cellspacing="0" cellpadding="0" style="width:100%">
                                              <tbody>
                                              <tr>
                                                <td class="responsive-td" valign="top" style="width: 100%;">
                                                  <div data-type="slot" data-key="emailfooter" data-label="Email Footer">
                                                  </div>
                                                </td>
                                              </tr>
                                              </tbody>
                                            </table>
                                          </td>
                                        </tr>
                                    </tbody>
                                  </table>
                                </td>
                              </tr>
                            </table>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td valign="top">
          <custom type="footer" />
        </td>
      </tr>
    </table>
  </body>
</html>

1 Answer 1

3

You’re using ContentAreaByName, which is is only for use with Classic Content areas. It does not retrieve content stored in Content Builder. To retrieve content from Content Builder by name, use the ContentBlockByName function.

Source: https://ampscript.guide/contentareabyname/

Replacing the function name in your code and adding correct folder path should fix it:

%%[set @number = 20]%%
%%= ContentBlockByName("Content Builder\...\emailfunction")=%% 
%%=v(@numberEvaluated)=%%
2
  • That's what i ended up doing; I was trying to figure out if this Classic Content Area was still supported or not. Thanks for answering.
    – user80446
    Commented Nov 4, 2020 at 15:11
  • Note not all Content Builder template types for the content ("emailfunction" above) will necessarily work. We've found template type Code Snippet to work for us.
    – Glen Mazza
    Commented Apr 21, 2023 at 22:30

You must log in to answer this question.