Print this page

Personalization strings break the URL when they are used in a mailto link in Marketing Cloud

Knowledge Article Number 000214016
A mailto link can be used to create a subject line and body in an email that is created by the link.  
<a href=" subject line goes here&body=Email body content goes here">

Due to the way a URL is constructed, special characters need to be encoded so that they are interpreted properly.  For the example above, the space characters need to be replaced with the URL encoded version of the character, "%20".
<a href="">
When adding a personalization string into a URL, a space character causes the link to break because the character delimiter for a personalization string is '%%'.  The email engine is not able to parse the character correctly.

There are two ways to avoid this behavior:
  • Ensure there are no space characters in any of the profile attributes used in a URL.
  • Use AMPscript to set a variable in place of the profile attribute containing a space character.



The following example shows how to insert a mailto link that generates an email with the subject line: "[First Name] has a question about an order", where [First Name] is a profile attribute used in the account.

1. Open the email for which you want to use the mailto link.
2. At the top of the email, open an AMPscript block and create the variable to contain the profile attribute value.
VAR @fname

3. Set the variable to the value of the profile attribute, and close the AMPscript block.  Since the profile attribute contains a space, make sure to enclose the attribute name with square brackets.
SET @fname = [First Name]

4. At the point in your email in which you wish the link to appear, create the mailto link.  
<a href="">

5. At the point in the URL at which you wish the personalization to appear, use a v() function to call the variable.  Make sure to encode the remaining spaces in the string with '%20'.
<a href="">

Related topics


promote demote