SOLVED

3 very crucial questions regarding Apache Velocity email script tokens in an email

Go to solution
Anonymous
Not applicable

Background: I have an email script that initializes a bunch of variables and then other smaller individual scripts that reference the initial variables. This works in the HTML email and plain text email, but there are 3 significant problems.

1. Where can I place my initial script token so that the other email scripts will populate in the subject line?

2. The initial email script token results in a lot of whitespace in the plain text version of the email. Since I have to place it at the very beginning of the email, the email has like 10 lines of whitespace at the top.

3. How do I properly create a link using an email script?

The way I have it now:

In the token:

#set ($directions = "google.com/maps/dir//Some+Place")

$directions

So here $directions is being printed — the actual link, that is.

In the HTML:

<a href="{{my.token}}">Directions</a>

The error I get in Safari: (see attachment)

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

Yes, you'd have to find a way to make the inner text and/or elements generated in Velocity as well.  Combining VTL-contributed HTML pieces (in token/s) with end-user-contributed pieces (in the email body itself, including in variables) is difficult-to-impossible.

A notable exception is using comment tokens (containing just the text "<!--" and "-->"), but that's for suppressing user content as opposed to merging VTL+user content in a functional way.

Standalone text or elements from each source can be combined, of course, but trying to construct <element>s from pieces of both is almost guaranteed to fail.

View solution in original post

17 REPLIES 17