How to send Email Notification when Salesforce CaseComment record is created?

How to send Email Notification when Salesforce CaseComment record is created?

EmailHeader triggerUserEmail should be used to send the Email Notifications for the Case Comment records created.

Reference Article:

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_casecomment.htm

Sample Apex Code:

CaseComment objCaseComment = new CaseComment(
    ParentId = '5003t00001icShAAAU',
    CommentBody = 'Testing Demo'
);
Database.DMLOptions objDMLOptions = new Database.DMLOptions();
objDMLOptions.EmailHeader.triggerUserEmail = true;
objCaseComment.setOptions( 
    objDMLOptions 
);
insert objCaseComment;

Leave a Reply