function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Unsubscribe Email Service

We are starting to send out mass emails from our Salesforce organization. I would like the people receiving the emails to be able to opt out of receiving mass emails. I has a look around for methods of doing this and found this, . Example 2 on the page is pretty much what i am looking for. So i copied the code from that page and set up a class in my salesforce called unsubscribe and pasted in the code. I then setup and email service that used this class. I tested this out by sending an email from my outlook to the email address it provided me with and put unsubscribe in the subject, however, it doesnt seem to work and im not sure why.


I have also created a workflow so when EmailOptOut is set to true it sends the contact an email saying opt out successfull. I am under the impression that i dont have to create a workflow and could include this in the unsunsbribe apex code, is this correct?


Any help would be great.




Hi mstev45,


Can you give more information about how it's not working?  Sometimes it's useful to scatter about debug statements so you can better understand what is happening in your code.




Rasmus MenckeRasmus Mencke

You can download this app and if you want customize the apex code behind it:


You need to create the email service address for where you can send the unsubscribe email.