3 Replies Latest reply on Dec 19, 2018 8:51 AM by Michael Florin

    Email scripting lexical error

    Phillip Wild

      Hi guys


      I'm struggling with an email script and I'm hoping that someone can help me debug. It seems pretty straightforward...or so I thought!


      I've replaced our domain and the field name with placeholders, but otherwise this is how the script appears:


      #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/Australia-600x350.jpg")


      #if(${lead.fieldname} == "Australia")

          #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/Australia-600x350.jpg")

      #elseif(${lead.fieldname} == "Burgundy")

          #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/Burgundy-600x350.jpg")

      #elseif(${lead.fieldname} == "Costa Rica")

          #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/Costa-Rica-600x350.jpg")

      #elseif(${lead.fieldname} == "India")

      #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/India-600x350.jpg")

      #elseif(${lead.fieldname} == "Japan")

      #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/Japan-600x350.jpg")

      #elseif(${lead.fieldname} == "Namibia")

      #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/Namibia-600x350.jpg")

      #elseif(${lead.fieldname} == "Peru")

        #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/Peru-600x350.jpg")

      #elseif(${lead.fieldname} == "USA")

        #set($HeaderImageURL = "letsgo.brand/rs/110-AIL-152/images/USA-600x350.jpg")









      The email script token is called "{{my.Header_Image}}". In the HTML itself, the image looks like this:


      <img src="http://{{my.Header_Image}}" width="600" border="0"  class="deviceWidth" style="display:block;border-width:0;-ms-interpolation-mode:bicubic;"/>


      I don't even get an error when I send a sample email, or a live deployment. The email soft bounces, and I get this error in the activity log:



      System send failure: Velocity transform failed: ; The nested exception is: <cntrl char>org.apache.velocity.exception.ParseErrorException: Lexical error, Encountered: " " (160), after : "" at *unset*[line 279, column 40]




      I know that's referring to the Velocity script, but I can't see the error in my code. Any ideas?


      Thanks, Phil

        • Re: Email scripting lexical error
          Sanford Whiteman

          Suspect you have an extra whitespace (charCode 160) character somewhere in there. It probably didn't transfer to the forum post, though.


          I would do it like this anyway, easier to maintain (you probably knew I was going to do this!):


          #set( $HeaderImageURLs = {
            "Australia" : "Australia-600x350.jpg",
            "Burgundy" : "Burgundy-600x350.jpg",
            "Costa Rica" : "Costa-Rica-600x350.jpg",
            "India" : "India-600x350.jpg",
            "Japan" : "Japan-600x350.jpg",
            "Namibia" : "Namibia-600x350.jpg",
            "Peru" : "Peru-600x350.jpg",
            "USA" : "USA-600x350.jpg",
            "*" : "Australia-600x350.jpg"
          } ) 
          #set( $HeaderPath = "letsgo.brand/rs/110-AIL-152/images/" )
          #set( $HeaderImageURL = $HeaderImageURLs["*"] )
          #set( $HeaderImageURL = $HeaderImageURLs[$lead.fieldname] )
          4 of 4 people found this helpful