Site icon Sunshine and Other Unhandled Exceptions

Unsubscribe Link

JULY 30, 2021 UPDATE: This version is now outdated! Please go here for the latest.


Unsubscribe Link 2.2 (OUTDATED)

Allow Recipients to Unsubscribe From All Email Sent via Salesforce

When the recipient clicks to unsubscribe, a flow will look for all contacts and leads who have this email in the Email field and mark them “Email Opt Out.”  The email address owner will receive one confirmation email immediately. A custom object tracks when someone unsubscribes to allow you to report on it.

See How It Works

UPDATE: 1/28/21 I realized how to send the confirmation email from someone other than “Site Guest User.” More in this post.

Set Up Instructions

Install the latest version from the AppExchange.

Make sure My Domain is set up. Instructions here from Trailhead.

Create a Site

Modify the Site Guest User

Modify the Custom Metadata Type

Field and Object Level Steps

Test It Out

The next page should look like this.

Success!

Email Templates

The Unsubscribe Link formula fields only work in Lightning Templates. As of Spring ’21, you can use Lightning Templates in all automation. I’ve included the code below for using the Unsubscribe Link with classic email templates.

I created two fields on Contact and Lead named the same thing, Unsubscribe_Link__c. That is causing confusion with Lightning templates that list the fields as {{{Recipient.Unsubscribe_Link__c}}}. So first of all, I’m sorry! And I will fix it in the next version. I highly suggest that you rename the Unsubscribe Link fields to be object specific to keep things clear. The steps to do so are outlined above.

Classic Email Templates

If you need to or want to use Classic email templates, you can! Get the classic HTML and Visualforce templates here. Unfortunately, the Unsubscribe Link merge fields don’t work in Classic so you need to use templates.

How to Uninstall the Package

If you have any Unsubscribe__c records from using this package, you’ll lose them by uninstalling.

How to Modify the Confirmation Email Body

In Spring ’21, you can include a Rich Text email in Flows! Hurray! That’s one reason you might want to change the email body. Or you might not like the text “You will no longer receive email from [our organization].”

How to Remove the Confirmation Email

Troubleshooting

If you’re seeing this error, it’s likely that your “My Domain” was set up to be http and not https. No worries! Just adjust your two formulas called Unsubscribe_Link__c – one on the Contact and and one the Lead objects. Change “https” to “http” in the formulas and somehow that makes it work, and it still runs as https!

Some people need to add the word “Unsubscribe” (capital U) as the default web address on the Site.

With this error, make sure you have given the Site Guest User access to the Visualforce page Unsubscribe Finish. See the “Modify the Site Guest User” section above.

If you still need help, and you’ve gone through all the instructions thoroughly a few times, you can email me. Create a contact or a lead in your database with my email address jrymph @ salesforce.com then send me an email that includes your unsubscribe link merge field. Subject: “Please help with unsubscribe link app.” Body: “I have followed all of your very through instructions and still need assistance. [Unsubscribe Link Merge field]. ” (Something like that).

Exit mobile version