Notes from the Dev logo blue

Notes from the Dev: Salesforce Email Coding Tips for Beginners 

An excellent way to evolve as an email geek is to learn how to develop campaigns in a variety of platforms and scripting languages. In this episode of Notes from the Dev: Video Edition, we’ll find out how to get started using one of the most popular solutions for marketing automation.

Salesforce Marketing Cloud (SFMC) has a nearly 23% market share in the CRM/automation space. That’s more than its next four closest competitors combined. So, if you’re going to learn how to code emails for a specific automation platform, you may as well start with the biggest player in the game.

Joining me in this episode are two SFMC email experts, Aysha Marie Zouain and Rodrigo Santander. Aysha is an email developer who now works as a product owner for City National Bank of Florida. Rodrigo is a Martech Solutions Architect based in Mexico City.

To show us how SFMC email coding works, they developed a special demo email just for Notes from the Dev. Check out the video and get more below. Plus, don’t miss the helpful documentation Aysha and Rodrigo shared with us, which is linked at the end of the article.

Why learning SFMC email development makes sense

Beyond the fact that Salesforce Marketing Cloud is a leading cloud-based software provider with a big chunk of the market, there are other good reasons to learn how to use the platform.

This is a valuable skill for freelance email developers to have. A lot of larger enterprise organizations use SFMC. So, if you want to land big-name clients, knowing your way around the software is going to give you a nice advantage.

Likewise, understanding how SFMC email creation and personalization works is also helpful if you work as a developer for a digital agency. It could even help you land your next full-time job. You will find companies out there actively seeking to hire Salesforce Marketing Cloud email specialists.

Whatever your motivation, it’s always a good idea to diversify your skillset as an email geek.

Email coding in Salesforce Marketing Cloud: The basics

The first thing Aysha and Rodrigo pointed out is that, like many platforms, there’s more than one way to create an email in Salesforce Marketing Cloud. You’ve got a no-code or WYSWIG solution, a low code option, and an option involving customized code snippets.

Aysha explains that the low-code approach to SFMC email creation involves the use of various content blocks, which you can use in conjunction with a simple email design system. The code snippet approach opens all SFMC’s capabilities in blocks that you develop from scratch.

Be aware that with SFMC email development, no-code/WYSWIG and low-code options may leave you with some issues to address. That includes a lack of semantic HTML, code bloat, and rendering problems in some clients because of things like additional <div>s. So, even if you’re not a developer, it’s still wise to click over to code view and make some adjustments.

“If you’re going to be doing this, I highly encourage you to learn the very most basic things about HTML.”

Rodrigo Santander, Martech Solutions Architect

When you start working in SFMC, you can choose to use an existing template or a simple email message. A Salesforce email message gives you the foundation of an HTML email including DOCTYPE declaration, some schemas, and specific CSS that Salesforce Marketing Cloud uses.

However, there are some things you should do with an SFMC email that the platform hasn’t done for you. That includes future-proofing the DOCTYPE by switching from transitional HTML (the default) to HTML5. You’ll then need to set your lang=" " attribute, and you should add XML schemas for vector image (VML) support in Outlook. Rodrigo also added some conditional code for MSO that allows for zooming on images in Outlook.

Controlling SFMC email access and permissions

Finally, Rodrigo suggests a small customization that helps others using your email know where they are able to add their own code. He uses what are known as slots in SFMC. Slots let you control and restrict the way content blocks are used.

Here’s the code:

<div data-type="slot" data-key="css" 
         data-label="Add your css content here">

Aysha tells us that setting SFMC permissions and restrictions can be very useful in enterprise organizations with larger teams. That also goes for agencies that may want to manage a client’s abilities to make changes. Even she and Rodrigo approach SFMC email development differently, and email production may get messy and confusing if you don’t standardize your processes.

“The cool but also dangerous thing about Salesforce Marketing Cloud is that you can make solutions in 50 different ways.”

Aysha Marie Zouain, SFMC Product Owner, City National Bank of Florida

Personalization and dynamic content in SFMC emails

Personalized campaigns with dynamic content take email marketing to the next level. Salesforce Marketing Cloud uses a proprietary language known as AMPscript for personalization. With SFMC, AMPscript is used to personalize landing pages, SMS, and push notifications as well as emails. That means you can create a cohesive, personalized experience between emails and landing pages.

AMPscript is powerful. But it can also be complicated. For more on getting started with the scripting language checkout the recording of this AMPscript Bootcamp webinar.

Rodrigo and Aysha created a fun email just for our show that they personalized for the three of us as well as an “unknown” subscriber. In the video, Rodrigo shows us how he used SFMC data extensions to power the personalization in this dynamic email. Depending on the recipient, the email displays a different photo, name, and animal based on what’s in the data extension. He shows us how to set up the variables and definitions for these personalizations.

Here’s a gallery of the four different personalized versions:

Aaysha personalized Salesforce email
Salesforce email personalized for Rodrigo
Megan in personalized SFMC email
unknown subscribers sfmc email fallback

A common roadblock to personalized emails is data that isn’t 100% clean. For example, a contact filled out a form using all lowercase letters, but you want their name and other data capitalized in your campaigns. Instead of editing what’s in your database, Aysha explains that you can fix this at the email template level using an AMPscript function called ProperCase.

Another potential personalization problem is a lack of subscriber data. Depending on how and where you acquired a contact, you may have a lot of information about them, or you may have nothing but an email address.

That’s why Rodrigo also demonstrated how to code an if/else statement in AMPscript that creates a fallback when data needed for personalization is missing. For example, the code below states that if the data for displayname is missing then use the text “Email Developer”. The else part of the statement concatenates a first and last name from the data extension.


var @firstName, @displayName 

set @firstName = FirstName 

if empty(@firstName) then 
  set @displayName = "Email Developer" 
  set @displayName = Concat(FirstName, " ", LastName) 


<p style="color: #00885a">
  Hi, I&rsquo;m an
<p style="color: #00885a">
  my favorite animal is:
Code view of personalized SFMC email fallback

One thing I asked about was if it’s alright to code the if/else statement the opposite way – placing the fallback options in the else statement – which is how I usually work. Our guests confirmed this is totally fine in SFMC. It once again boils down to different developers working in different ways.

Another tip Rodrigo provided was to place the code for the personalization in a code snippet block to keep Salesforce Marketing Cloud from modifying it. Once all four of those content blocks were made, Rodrigo used a dynamic content block to allow different variations depending on the information in the data extension.

So, with the dynamic content block, if the FirstName is “Megan” it pulls in the complete content block with my name, picture, and favorite animal.

More from Aysha and Rodrigo

We’re so grateful for the time and effort these two put into building this original email for us and for showing us a little bit about how Salesforce Marketing Cloud works. Both Aysha and Rodrigo are available to connect if you have questions on SFMC email coding.

Connect with Aysha on LinkedIn or find her on Twitter. She is also one of the founders of the website, which is a place where you can find even more information on the platform.

You can find Rodrigo on LinkedIn or follow him on Twitter as well. He has founded a Spanish-language website/community called Friends of Email where he offers tips and advice.

Finally, if you want to recreate this episode’s email in Salesforce Marketing Cloud, or play around with your own version, our guests have graciously put together a cheat sheet that breaks it all down piece by piece.

More tips from the biggest email geeks in the world are on the way. Don’t miss an episode. Subscribe to Email on Acid’s YouTube channel and be the first to see what’s next.

Built for Busy Email Teams

Your team needs an email readiness platform that scales as you grow and take on more work. Sinch Email on Acid lets you manage projects and permissions while collaborating throughout the pre-deployment process. Find out why so many recognizable brands trust Sinch Email on Acid for delivering email perfection. Discover our Enterprise Solutions.

Get a Custom Demo