Email Services sample code for how to unsubscribe from emails | Salesforce Developers Blog

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

Stay up to date with the latest news from the Salesforce Developers Blog