Task t = new Task();
t.WhatId = 'custom object Id';
t.OwnerId = 'userid';
t.Subject = 'Test';
t.Priority = 'High';
t.Status = 'Test Status';
t.Description = 'Test Note.Description__c';

Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerUserEmail = true;
List<Database.saveresult> sr = Database.insert(new list<Task>{t},dlo);

trying to execute code in dev console but user is not receiving any email.

  • Your code says triggerUserEmail = false, shouldn't that be TRUE.
    – Matt M
    Oct 6, 2016 at 20:55
  • @MattM ahh yeah may be typo.. thanks for pointing this out.
    – Ratan Paul
    Oct 7, 2016 at 4:53

1 Answer 1


Found the issue. under Activity Settings we need to check Enable User Control over Task Assignment Notifications checkbox.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .