+ Start a Discussion

Email Template issue



I am new in salesforce and I have a problem.  when my application receive an email it reply with an email template, i have a lot of different email templates and my application reply depending of the subject of the email that was received.


The problem is that i don't know if the user of the application will be able to update and delete the email templates because if the user of the application update or delete the email templates my application will not work.


I send the email templates with an apex class, here is my code where i send one of the templates:


Contact recipient2 = [SELECT id FROM Contact WHERE Email=:email.FromAddress LIMIT 1];                
EmailTemplate alert = [SELECT id FROM EmailTemplate WHERE developerName = 'registration'];
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });


If the user of the application change the developerName of the email template my class will not find it with the query.

I want to know how validate that the user of the application don't update the developerName or delete any email template that I use in the apex class but if the user create other email template then that template can be modified or deleted.


All help is greatly appreciated.

Best Answer chosen by Admin (Salesforce Developers) 

You can't prevent a template from being deleted or otherwise mangled. Instead, you'll have to have some sort of fallback plan, such as sending a generic template or text, or sending a notification to an admin that something broke.