Custom Tokens in Email Campaign Manager
Recently I had a requirement from a client where they wanted to use Sitecore Email Campaign Manager to send registration emails, containing registration details and other dynamic custom data. Here is how to create tokens within a Email Campaign message and replace them with variables in a manually triggered email.
- Add your token(s) into the body text of the campaign message in the format $key$, ensure that the key text is lower case.
Sitecore Email Campaign Manager Custom Tokens
- Get the message using the Sitecore API, replace the variables using the CustomPersonTokens dictionary and then trigger the send pipeline. The CustomPersonToken dictionary requires the key to be in lower case and requires the surrounding $$ to be removed.
Trigger Email and Replace tokens
Here is a reusable function that allows you to send an email campaign message from code and replace custom tokens.