A Few More Email Scripting Examples | Community
Skip to main content
March 22, 2016

A Few More Email Scripting Examples

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

    This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

    12 replies

    Jason_Hamilton1
    Level 6
    March 22, 2016

    Awesome, thanks Kristen

    Translate
    Grégoire_Miche2
    Level 10
    March 22, 2016

    Thx a lot Kristen.

    -Greg

    Translate