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
sfdcsushilsfdcsushil 

triggerUserEmail email header not sending emails for Tasks

Hello,

I have some code which creates a  task for one user when an opportunity is created. during creation of tasks, i am setting up the Email header for sending emails. But emails are not being sent for some reason.

Code Snippet - 
          Database.DMLOptions dml = new Database.DMLOptions();
          dml.emailHeader.triggerUserEmail = true;
          database.insert(lstTasks, dml);

Can someone provide some pointers for fixing this issue. Thanks in Advance. 
nikvmnikvm
Chekc your email Deliverability settings. Make sure Access Level is set to All Emails. 
sfdcsushilsfdcsushil
Email Deliverability is correctly set to All Emails. FYI, Its working fine when you create task manually and select sent notification to assignee. 
nikvmnikvm
I found this article https://help.salesforce.com/apex/HTViewSolution?id=000176854&language=en_US
did you happen to have a look. 
 
nikvmnikvm
usinf @future might help.