A Few More Email Scripting Examples

Not applicable

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)


## Show result


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))