You need to sign in to do that
Don't have an account?
AmbigaRam
how to display the case number in email template?
Hi,
The following is the content of my email template, and my template name is "Case email"
"Thanks , Your case number is {!Case.CaseNumber}"
And my Apex Trigger to send the email, when the case is created.
trigger mailNotification on Case ( after insert) { contact CaseContact; for(case Cases :trigger.new){ //Fetch the related case contact. CaseContact = [SELECT Email FROM Contact WHERE Id = :Cases.ContactId]; if (CaseContact != null && CaseContact.Email != null) { Messaging.SingleEmailMessage CaseNotificationmail = new Messaging.SingleEmailMessage(); EmailTemplate template = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'Case Email ']; CaseNotificationmail.setToAddresses(new List<String> { CaseContact.Email }); CaseNotificationmail.setReplyTo('someone@salesforce.com'); CaseNotificationmail.setSenderDisplayName('Salesforce Support'); CaseNotificationmail.setTargetObjectId(CaseContact.Id); CaseNotificationmail.setTemplateId(template.id); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { CaseNotificationmail }); } } }
after creating the case, It sends the mail, but It does nt show the case number.
Can anybody help for this?
Regards.,
Ambiga.R
Hi,
Thanks Sujit Nirke, but It does not work!
Regards
Ambiga.R