I'm assigning lead ownership via apex triggers (before insert, before update) and would like to not have it send out the "Lead: [full name] has been assigned to you" email to the new owner. How do I stop those from going out?
Side note: I'm assigning via apex trigger because it's dependent on some other territory assignments that happen based on address during the before insert and before update triggers already, so I'm not interested in Lead Assignment Rules as a solution…
Best Answer
You want to use the
DmlOptions.EmailHeader
Class for this. The class has 3 properties that can send or suppress system emails. The property you are looking for istriggerUserEmail
. Here is an example of how you would use itHere is a link to the documentation
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_class_Database_EmailHeader.htm
EDIT
If you are working with beforte triggers, this will not work. From the docs
Here is a knowledge article that gives the workaround of using future methods to make this work
https://help.salesforce.com/apex/HTViewSolution?id=000176854&language=en_US