Here's the solution for your question using Trigger.
Trigger =>
trigger DevQ2Trigger on Task (before insert,before update) {
DevQ2.ans(Trigger.new);
}
Handler Class =>
public class DevQ2 {
public static void ans(List<Task> tList){
for(Task t:tList){
if(t.status == 'Completed'){
User owner = [Select name,email from user where id =:t.ownerId limit 1];
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new String[]{ owner.Email });
email.setSubject('Reminder: Task "' + t.Subject + '" is completed');
email.setPlainTextBody('Dear ' + owner.Name + ',\n\nThis is a friendly reminder
that the following task is now completed:\n\n' + t.Subject);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
}
}
}
}
Check below example for custom email notification for completed tasks
https://automationchampion.com/2022/03/10/custom-email-notification-for-completed-tasks-2/
Also there is a limitation around email notification for task creator.
https://ideas.salesforce.com/s/idea/a0B8W00000GdmP0UAJ/send-email-notification-for-completed-tasks-to-task-creator
Please mark as Best Answer if above information was helpful.
Thanks,
Here's the solution for your question using Trigger.
Trigger =>
Handler Class =>
Hope this is helpful.
Thank you.