4
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;
t.setOptions(dlo);
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 '16 at 20:55
  • @MattM ahh yeah may be typo.. thanks for pointing this out. – Ratan Paul Oct 7 '16 at 4:53
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.