0

I am trying to use an ampscript "If ELSE statement to enter HTML code into a table. But I keep getting an error "There is an error in your email. Please contact your customer service representative. Error 1: Script IF Not Closed
An IF statement is not closed with the required ENDIF statement.
Invalid Content:
IF (@veh_model_name == "Mirage") THEN]%% https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002"

I not sure where I am going wrong. Please help!!

Here is my AMPscript code I am inserting into the HTML table:

<tr class="register-container-row" bgcolor="#ffffff" style="width: 700px;line-height:0;font-size:0;" width="700">
  <td>
    <table border="0" cellpadding="0" cellspacing="0" style="border-spacing:0;border:0;">
      <tbody>
        <tr style="line-height: 0;">
          <td style="font-size:0;">
            %%[IF @veh_model_name == "Mirage" THEN <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-01-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            ELSE IF @veh_model_name == "Lancer" OR @veh_model_name == "Lancer SportBack" THEN
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-05-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            ELSE IF @veh_model_name == "Lancer Evolution" THEN
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-06-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            ELSE IF @veh_model_name == "MirageG4" THEN
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-02-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            ELSE IF @veh_model_name == "Outlander" THEN
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-03-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            ELSE IF (@veh_model_name == "Outlander Sport") THEN
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-04-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
             %%[ endif ]%%
          </td>
        </tr>
      </tbody>
    </table>
5

You were not closing each ampscript block inbetween the HTML content. Any time you switch back to HTML you need to close the AMPscript and any time you switch from HTML back to ampscript you need to open the tag.

See below:

 <tr class="register-container-row" bgcolor="#ffffff" style="width: 700px;line-height:0;font-size:0;" width="700">
  <td>
    <table border="0" cellpadding="0" cellspacing="0" style="border-spacing:0;border:0;">
      <tbody>
        <tr style="line-height: 0;">
          <td style="font-size:0;">
            %%[IF @veh_model_name == "Mirage" THEN]%% <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-01-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            %%[ELSEIF @veh_model_name == "Lancer" OR @veh_model_name == "Lancer SportBack" THEN]%%
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-05-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            %%[ELSEIF @veh_model_name == "Lancer Evolution" THEN]%%
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-06-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            %%[ELSEIF @veh_model_name == "MirageG4" THEN]%%
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-02-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            %%[ELSEIF @veh_model_name == "Outlander" THEN]%%
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-03-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
            %%[ELSEIF (@veh_model_name == "Outlander Sport") THEN]%%
            <a href="https://www.mitsubishicars.com/owners/registration?cid=crm_em_html_july_anniversary_Full_engagement_002">
              <img alt="REGISTER" width="700" height="200" src="http://assets.rurl360.com/Possible/Asset/MA-register-04-d.jpg" style="width: 700px; height: 200px; border:none;">
            </a>
             %%[ endif ]%%
          </td>
        </tr>
      </tbody>
    </table>
|improve this answer|||||
  • I am still getting the same error when trying preform a send preview in ET. – David Mc Sep 13 '17 at 19:29
  • Here the error after in iserted your code – David Mc Sep 13 '17 at 19:29
  • "There is an error in your email. Please contact your customer service representative. Error 1: Script IF Not Closed An IF statement is not closed with the required ENDIF statement. Invalid Content: IF (@veh_model_name == "Mirage") THEN]%% mitsubishicars.com/owners/…" – David Mc Sep 13 '17 at 19:29
  • I missed it. It should be ELSEIF not ELSE IF. Will edit answer – Gortonington Sep 13 '17 at 20:29
  • Ok that seem to fix the error...Thanks Gortonington! Now the images did not pull in. I got to take a look at that now. – David Mc Sep 13 '17 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.