Concatenate a URL

When you add parameters to a URL, add the first parameter using a question mark (?), and every subsequent parameter using an ampersand (&).

No Parameters
http://tabletrtd.com

One Parameter
http://tabletrtd.com?parameter1

Multiple Parameters
http://tabletrtd.com?parameter1&parameter2&parameter3

Variable Content by ESP

SFMC (ExactTarget)

%%[if emailversion == "V1" then]%%
V1 CONTENT GOES HERE
%%[elseif emailversion == "V2" then]%%
V2 CONTENT GOES HERE
%%[else]%%
DEFAULT CONTENT GOES HERE
%%[endif]%%

Campaign Monitor

[if:emailversion=V1]
V1 CONTENT GOES HERE
[elseif:emailversion=V2]
V2 CONTENT GOES HERE
[else]
DEFAULT CONTENT GOES HERE
[endif]

MailChimp

*|IF:emailversion=V1|*
V1 CONTENT GOES HERE
*|ELSEIF:emailversion=V2|*
V2 CONTENT GOES HERE
*|ELSE:|*
DEFAULT CONTENT GOES HERE
*|END:IF|*

Removing Orphans and Widows

Add a non-breaking space ( ) between the last two words of every paragraph, between words you don’t want to break apart, or a non-breaking hyphen (​) as the hyphen in hyphenated words. This will keep your live text from leaving an orphan/widow hanging out alone (and sad).

Note: Do not use padding, or a tight space to try to fix this for live text. Doing so can cause undesirable effects across email clients.

I am a sentence that might break apart if nobody fixes me.

I am a sentence that might need a non​breaking hyphen.

Buttons (CTAs)

Standard

<table cellpadding="0" cellspacing="0" border="0" width="150">
  <tr>
    <td align="center" valign="middle" height="42" bgcolor="#3a3a3a" style="font-family:Arial, Helvetica, sans-serif; font-size:18px; mso-line-height-rule:exactly; line-height:22px; color:#ffffff; padding:0 0 0 0;"><strong><a href="http://tabletrtd.com/" target="_blank" style="color:#ffffff; text-decoration:none; display:block; padding:10px 10px 10px 10px;">CTA</a></strong></td>
  </tr>
</table>

Rounded

<table cellpadding="0" cellspacing="0" border="0" width="150">
  <tr>
    <td align="center" valign="middle" height="42" bgcolor="#3a3a3a" style="font-family:Arial, Helvetica, sans-serif; font-size:18px; mso-line-height-rule:exactly; line-height:22px; color:#ffffff; padding:0 0 0 0; border-radius:21px;"><strong><a href="http://tabletrtd.com/" target="_blank" style="color:#ffffff; text-decoration:none; display:block; padding:10px 10px 10px 10px;">CTA</a></strong></td>
  </tr>
</table>

Bordered

<table cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td bgcolor="#3a3a3a" style="padding:2px 2px 2px 2px;">
      <table cellpadding="0" cellspacing="0" border="0" width="150">
        <tr>
          <td align="center" valign="middle" height="42" bgcolor="#a3a3a3" style="font-family:Arial, Helvetica, sans-serif; font-size:18px; mso-line-height-rule:exactly; line-height:22px; color:#ffffff; padding:0 0 0 0;"><strong><a href="http://tabletrtd.com/" target="_blank" style="color:#ffffff; text-decoration:none; display:block; padding:10px 10px 10px 10px;">CTA</a></strong></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

Rounded and Bordered

<table cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td bgcolor="#3a3a3a" style="padding:2px 2px 2px 2px; border-radius:25px;">
      <table cellpadding="0" cellspacing="0" border="0" width="150">
        <tr>
          <td align="center" valign="middle" height="42" bgcolor="#a3a3a3" style="font-family:Arial, Helvetica, sans-serif; font-size:18px; mso-line-height-rule:exactly; line-height:22px; color:#ffffff; padding:0 0 0 0; border-radius:21px;"><strong><a href="http://tabletrtd.com/" target="_blank" style="color:#ffffff; text-decoration:none; display:block; padding:10px 10px 10px 10px;">CTA</a></strong></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

Background Image

<table cellpadding="0" cellspacing="0" border="0" width="150">
  <tr>
    <td align="center" valign="middle" height="42" bgcolor="#3a3a3a" background="http://placehold.it/10x10" style="font-family:Arial, Helvetica, sans-serif; font-size:18px; mso-line-height-rule:exactly; line-height:22px; color:#ffffff; padding:0 0 0 0;"><strong><a href="http://tabletrtd.com/" target="_blank" style="color:#ffffff; text-decoration:none; display:block; padding:10px 10px 10px 10px;">CTA</a></strong></td>
  </tr>
</table>

Note: On the PC versions of Outlook only the text is clickable and the background image will not show. The code will fall back gracefully to the background color.

Email Build Checklist
















Responsive Bulletproof Background

Need Stig’s Bulletproof Background to become responsive for mobile? Add this class to the <td> and this css to your media query.

<td class="bgImage" background="https://i.imgur.com/YJOX1PC.png" bgcolor="#7bceeb" width="120" height="92" valign="top">
  VML AND CONTENT GOES HERE
</td>

css

<style type="text/css">
@media only screen and (max-width: 480px), only screen and (max-device-width: 480px) {
.bgImage {
    background-size: 100% 100% !important;
    height: auto !important;
}
}
</style>

Border

Standard – Add a border to a <td> (instead of a table). Feel free to use shorthand for the CSS on a border.

<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td align="left" valign="top" style="border:1px solid #3a3a3a;">
      <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
          <td align="left" valign="top" style="font-family:Helvetica, Arial, sans-serif; font-size:14px; mso-line-height-rule:exactly; line-height:18px; color:#3a3a3a; padding:20px 20px 20px 20px;">Bordered Text</td>
        </tr>
      </table>
    </td>
  </tr>
</table>

Works Everywhere – This is not really a border border 😉 We are currently really loving this technique.

<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
    <td align="left" valign="top" bgcolor="#3a3a3a" style="padding:1px 1px 1px 1px;">
      <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
          <td align="left" valign="top" bgcolor="#ffffff" style="font-family:Helvetica, Arial, sans-serif; font-size:14px; mso-line-height-rule:exactly; line-height:18px; color:#3a3a3a; padding:20px 20px 20px 20px;">Bordered Text</td>
        </tr>
      </table>
    </td>
  </tr>
</table>

SFMC (ExactTarget) AMPscript Snippets

We use these all the time!

Pull in a date

Current Year
%%=Format(Now(), "yyyy")=%%

Date that will update continually
%%=Format(Now(), "MM/dd/yyyy")=%%

Date that is hard set from time of send
%%=Format(Now(true), "MM/dd/yyyy")=%%

Date plus days
%%=Format(DateAdd(Now(true), "14", "D"), "MM/dd/yyyy")=%%

Casing

%%=ProperCase(variable)=%%
%%=UpperCase(variable)=%%
%%=LowerCase(variable)=%%

Links

Redirect for concatenated or variable
%%[set @variable = variable]%%
href="%%=RedirectTo(@variable)=%%"

Removing tracking
href="%%=concat('link you do NOT want to track')=%%"

System level variables

view online = %%view_email_url%%
email address = %%emailaddr%%
forward to a friend = %%ftaf_url%%
unsubscribe = %%unsub_center_url%%
profile center = %%profile_center_url%%
subscription center = %%subscription_center_url%%
sender reply name = %%replyname%%
sender reply email address = %%replyemailaddress%%
business name = %%Member_Busname%%
business address = %%Member_Addr%%
business city = %%Member_City%%
business state = %%Member_State%%
business postal code = %%Member_PostalCode%%
business country = %%Member_Country%%

View Online
<a href="%%view_email_url%%" alias="View_Online" target="_blank" style="color:#3182c1; text-decoration:none;">View Online</a>
Profile Center
<a href="%%profile_center_url%%" alias="Update_Profile" target="_blank" style="color:#3182c1; text-decoration:none;">Update Profile</a>
Unsubscribe Center
<a href="%%unsub_center_url%%" alias="Unsubscribe" target="_blank" style="color:#3182c1; text-decoration:none;">Unsubscribe</a>

Space in Field Header Name

%%[
set @FirstName = [First Name]
]%%

Hiding content on web

%%[if _messagecontext != "vawp" then]%%
content hidden on web
%%[endif]%%

Hiding content on forward to a friend

%%[if _messagecontext != "ftaf" then]%%
content hidden on forward to a friend
%%[endif]%%

Formatting

Date
%%=Format(variable, "dddd, MMMM d")=%%
%%=Format(variable, "MM/dd/yyyy")=%%

Time
%%=Format(variable, "h:mm tt")=%%
%%=Format(variable, "HHmmss")=%%

Phone number
%%=Format(variable,"###-###-####")=%%

Currency
%%=Format(variable,"$#,#.00;-$#,#.00")=%%

Dynamic Subjectline

This lives in the Properties of the HTML Paste
%%=v(@subjectline)=%%

This lives between the closing style tag and the closing head tag
%%[
set @firstname = ProperCase(firstname)

/*Is there a First Name in the Subjectline? Y or N*/
set @firstNameVersion = "N"

if empty(firstname) or @firstNameVersion == "N" then
set @subjectline = "TBD"
else
set @subjectline = concat(@firstname,", TBD")
endif
]%%

Pull in a Content Area

Classic Builder
%%=ContentArea("UniqueID")=%%

Content Builder
%%=ContentBlockbyID("UniqueID")=%%

Raise Error

%%[else RaiseError("Write Error Sentence Here", true) endif]%%

Find a content in a string

%%[if IndexOf(variable,"this") > 0 then
Write set Statement Here
endif]%%

Replace content in a string

%%[set @variable = Replace(variable,"old","new")]%%

Micro base URL

%%microsite_base_url[default]UniqueID[/default]%%

Target a specific domain

%%[if domain(emailaddr) == "domain.com" then]%%

Lookup Table

%%[
set @fieldData = fieldData
set @variable = Lookup("lookupTableName","fieldHeaderForVariable","matchbackVariable",@fieldData)
]%%

Lookup Table with Row Count

%%[
set @rows = LookupRows("lookupTableName","matchbackVariable",matchbackVariable)
if RowCount(@rows) > 0 then
  set @row = Row(@rows,1)
  set @variable1 = Field(@row,"fieldHeaderForVariable1")
  set @variable2 = Field(@row,"fieldHeaderForVariable2")
endif
]%%

AMPscript Looping Tips

Use the Lookup Table AMPscript in the body, wrapped around your content you want looping.

We suggest looping full stacked <tables> or full stacked <tr>s.

Call variables using %%=v(@variable)=%% in the body.

Loop with Sendable List matching to Lookup Table

Sendable List or Data Extension
emailAddress matchbackVariable
this@emailaddress.com 0239485
that@emailaddress.com 7462829
theother@emailaddress.com 0239485
Lookup Table (Data Extension)
matchbackVariable fieldHeaderForVariable1 fieldHeaderForVariable2
7462829 Tacos Mardi Gras
0239485 Spaceships Spain
0239485 Spinach Alfredo The Bathroom
0239485 Radios The Beastie Boys Recording Studio
%%[ set @rows = LookupRows("lookupTableName","matchbackVariable",matchbackVariable) for @i = 1 to rowCount(@rows) do set @row = Row(@rows,1) set @variable1 = Field(@row,"fieldHeaderForVariable1") set @variable2 = Field(@row,"fieldHeaderForVariable2") ]%% <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td align="left" valign="top"> (CONTENT TO BE LOOPED) I love when table tr td sends me %%=v(@variable1)=%% from %%=v(@variable2)=%%. </td> </tr> </table> %%[next @i endif]%%

Loop with Lookup Table Only

Lookup Table (Data Extension)
matchbackVariable fieldHeaderForVariable1 fieldHeaderForVariable2
fieldData Tacos Mardi Gras
fieldData Spaceships Spain
fieldData Spinach Alfredo The Bathroom
%%[ set @matchbackVariable = "fieldData" set @rows = LookupRows("lookupTableName","matchbackVariable",@matchbackVariable) for @i = 1 to rowCount(@rows) do set @row = Row(@rows,1) set @variable1 = Field(@row,"fieldHeaderForVariable1") set @variable2 = Field(@row,"fieldHeaderForVariable2") ]%% <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td align="left" valign="top"> (CONTENT TO BE LOOPED) I love when table tr td sends me %%=v(@variable1)=%% from %%=v(@variable2)=%%. </td> </tr> </table> %%[next @i endif]%%

Loop with a Grouping

%%[
set @rows1 = LookupRows("lookupTableName","matchbackVariable",matchbackVariable)
if RowCount(@rows1) > 0 then
  set @row1 = Row(@rows1,1)
  set @groupingVariable = Field(@row1,"groupingVariable")
endif

set @oneItem = "0"
set @multipleItems = "0"
set @previousItemNumber = ""
set @rows2 = LookupOrderedRows("lookupTableName",0,"groupingVariable ASC","matchbackVariable",matchbackVariable)
for @i = 1 to rowCount(@rows2) do
  set @row2 = Row(@rows2,@i)
  set @groupingVariable = Field(@row2,"groupingVariable")
  set @variable1 = Field(@row2,"fieldHeaderForVariable1")
  set @variable2 = Field(@row2,"fieldHeaderForVariable2")

  set @rows3 = LookupRows("lookupTableName","matchbackVariable",matchbackVariable,"groupingVariable",@groupingVariable)
  set @groupingVariableQuantity = RowCount(@rows3)

  if @groupingVariableQuantity == "1" then
    set @oneItem = "1"
    set @multipleItems = "0"
  elseif @previousItemNumber == @groupingVariable then
    set @oneItem = "0"
    set @multipleItems = add(@multipleItems, 1)
  else
    set @oneItem = "0"
    set @multipleItems = "1"
  endif

  if @oneItem == "1" or @multipleItems == "1" then
]%%
  <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
      <td align="left" valign="top">
        (CONTENT TO BE LOOPED AND GROUPED)
        I love when table tr td sends me %%=v(@variable1)=%% from %%=v(@variable2)=%%.
      </td>
    </tr>
  </table>
%%[
  else
  endif

  set @oneItem = "0"
  set @multipleItems = @multipleItems
  set @previousItemNumber = @groupingVariable

next @i endif
]%%