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.