Basically I am trying to create some email templates that send out to our users that contain a phone number. A lot of these phone numbers are formatted with no parathensis or dashes, and are in the form 1234567899, but our users would like them to appear on the template as (123) 456-7899.

I know we could do this with a formula field that will break it up and add the characters, but I am wondering if there is a way to tell the template directly to format the merge field being provided in this manner.

1 Answer 1


Yes - this is possible if you use a visualforce email template:

({! LEFT('1234567899', 3) }) {! LEFT(RIGHT('1234567899', 7), 3) }-{! RIGHT('1234567899', 4) }

If you place the above in a visualforce email template it will format string '123456789' with the text you want.

Replace '1234567899' with merge field like:

 ({! LEFT(relatedTo.Phone , 3) }) {! LEFT(RIGHT(relatedTo.Phone, 7), 3) }-{! RIGHT(relatedTo.Phone, 4) }
  • Exactly what I was looking for! Thanks so much Feb 4, 2020 at 19:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .