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")
#else
#end
$HeaderImageURL
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
Solved! Go to Solution.
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] )
${HeaderPath}${HeaderImageURL}
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] )
${HeaderPath}${HeaderImageURL}
Thanks so much! Works like a charm.
Still unsure why it didn't work the first time, but yours is much more elegant.
Thanks!
Just wanted to mention that this "extra whitespace" remark was also the solution to a related email script problem I had. Thanks Sanford Whiteman!