You need to sign in to do that
Don't have an account?
Dave The Rave
Apex Trigger send email with email template on case creation
Hi All,
When a case is created an email should be sent with email template (classic) to the email address from field <case.suppliedemail> and not email address in contact or account object.
Dave
When a case is created an email should be sent with email template (classic) to the email address from field <case.suppliedemail> and not email address in contact or account object.
- Case Created
- case.weborigin__c <> BLANK
- send email with email template using case.suppliedemail if case.suppliedemail is BLANK use case.contactemail
- In the first scenario a case is created via the web-to-case functionality, in the second scenario a user creates a case and links the case to a contact and account. In the first scanario they may not be an account or contact related to the case.
- I have several templates based on <case.country__c>
- If c.country__c = A then template A should be sent
- If c.country__c = B then template B should be sent
Dave
{
system.debug('@@@@@@@@@@@@@@@@@' + trigger.new[0].SuppliedEmail);
string emailId=trigger.new[0].SuppliedEmail;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
list<String> toAddresses=new list<string>();
toAddresses.add(emailId);
mail.setToAddresses(toAddresses);
mail.setReplyTo('support@acme.com');
mail.setSenderDisplayName('Salesforce Support');
mail.setSubject('New Case Created : ' + trigger.new[0].Id);
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setPlainTextBody('Your Case: ' + trigger.new[0].Id +' has been created.');
mail.setHtmlBody('Your case:<b> ' + trigger.new[0].Id +' </b>has been created.<p>'+
'To view your case <a href=https://na1.salesforce.com/'+trigger.new[0].Id+'>click here.</a>');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}