You need to sign in to do that
Don't have an account?
Cannot send email to Case Owner
Help!!
Issue: I have an APEX script that reassigns to a specific owner based on certain criteria (effectively bypassing Auto Assignment rules). This works fine, however I'm trying to code an emailCaseOwner(Case) function that emails the case owner after it's assigned. The trigger I'm passing is Case update before. The email that is ultimately sent to the case.OwnerID is not populating the merge fields.
The email template is used as the "Case Assigned Template" (Setup -> Customize -> Case -> Support Settings). I'm basically mimicing the checkbox when manually assigning a case owner "Send Notification Email".
End result of email being sent to assigned user:
Force.com Sandbox
Case Number: -
Client: -
Created by:
Subject:
Description:
APEX Code:
public static void emailCaseOwner(Case a)
{
EmailTemplate template = [select Id from EmailTemplate where Name = 'NewCase4CRC' limit 1];
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTargetObjectId(tempContact.Id);
mail.setTemplateId(template.Id);
mail.saveAsActivity = false;
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } );
}
Template Snippet:
Case Number: {!Case.CaseNumber} - {!Case.Product__c}
Client: {!Case.Contact} - {!Case.Account} {!Contact.Phone} {!Contact.Email}
Created by: {!Case.CreatedBy} {!Case.CreatedDate}
{!Case.Link}
Subject: {!Case.Subject}
Description: {!Case.Description}