Salesforce Developers Blog

Force.com Email Services sample code for how to unsubscribe from emails

Avatar for Rasmus MenckeRasmus Mencke
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 Force.com Email Services to process unsubscribe requests from the email recipients.
February 19, 2008
Listen to this article
0:00 / 0:00

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 Force.com 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

More Blog Posts

Using AI Model Output in Data Cloud with Prediction Jobs

Using AI Model Output in Data Cloud with Prediction Jobs

Use Einstein Studio prediction jobs to use AI models to score records sourced from Data Cloud. Automate business rules based on the results of your predictions.December 10, 2024