Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To create a unique URL for our customers in an email (to review our services on another website) I will need to use the BASE64 version of the person's email address and append that to the URL as a query string.

For example

so using my email address ( that would be this:

Of course I can't use online Base64 calculators since this email would go out to a lot of people in an automated fashion.

So the question is... Is it possible to build up an AMPscript that would do this conversion?

I looked around and haven't found any clue how the conversion is happening. If we would know that (or you might already do), we just need to replicate the calculation steps with AMPscript, I reckon.

What do you think?

edit: actually I found how roughly the calculation is happening:

Base64 encoding takes three bytes, each consisting of eight bits, and represents them as four printable characters in the ASCII standard. It does that in essentially two steps.

Rest is here:

share|improve this question
up vote 2 down vote accepted

Balint, I think the following block of code should accomplish your goal by using the Base64Encode function of AMPscript (

SET @email = ''
SET @email64 = Base64Encode(@email)
SET @url = Concat('', @email64)

<a href='%%=RedirectTo(@url)=%%'>Your Link</a>
share|improve this answer
oh there is actually a function for this already? thats brilliant. wow thanks a lot Brandt, that helped a lot. – Balint Aug 22 '14 at 13:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.