I wanted to share a few more email scripting examples with you.
Example 1: This script lowercases a string (in this case First and Last Name) and then properly capitalizes it.
(I think the previous example I gave only capitalizes the first letter, so if you had mixed case or all capitalized letters, it is not as good as this one.)
#set ($fname = ${lead.FirstName.toLowerCase()})
#set ($lname = ${lead.LastName.toLowerCase()})
$display.capitalize($fname) $display.capitalize($lname)
Example 2: This script adds a date 14 days in the future onto a token being used in an email.
## Access Velocity's calendar object
#set($x = $date.calendar)
## Format date
#set($current_date = $date.full_date)
## Add 24 hours (hours=int code 10 - see list below)
$x.add(6,14)
## Show result
$current_date
Example 3: This script gets the current date from the calendar object, converts it to a date and then reformats it to the format highlighted in yellow.
#set ( $todayCalObj = $date.toCalendar($date.toDate("yyyy-MM-dd H:m:s",$date.get('yyyy-MM-dd H:m:s'))) )
#set ( $dateObj = $date.toDate("yyyy-MM-dd", $todayCalObj) )
#set($dateFormatted = $date.format("MM/dd/yyyy", $dateObj))
$dateFormatted
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.