Take the 2-minute tour ×
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.

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 https://www.trustpilot.com/evaluate/www.kaplaninternational.com?b=%%emailaddress%%

so using my email address (sbi85g@gmail.com) that would be this: https://www.trustpilot.com/evaluate/www.kaplaninternational.com?b=c2JpODVnQGdtYWlsLmNvbQ==

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: http://email.about.com/cs/standards/a/base64_encoding.htm

share|improve this question

1 Answer 1

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 (https://code.exacttarget.com/content-scripting/ampscript/encryption/Base64Encode.html)

%%[
SET @email = 'sbi85g@gmail.com'
SET @email64 = Base64Encode(@email)
SET @url = Concat('https://www.trustpilot.com/evaluate/www.kaplaninternational.com?b=', @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 at 13:53

Your Answer

 
discard

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.