Most companies send out marketing emails to their customers and
prospects, and need a way to allow them to unsubscribe from your email
messages. This sample code shows how you can write Email
Services to process unsubscribe requests from the email recipients.

  • The code will search in the subject line for the word “unsubscribe”
  • If the words is found, I will first find all contacts who
    matches the from Email Address and set the HasOptedOutOfEmail to true
  • Then I search though the Leads and look for the same email address and updates the HasOptedOutOfEmail to true as well
  • The code then returns true and exists

See sample code here

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS