+ Start a Discussion

Edit email template in apex code


I have a requirement to edit the email template via apex code.

i need to display all the email template name in drop down and when we select one of them and i want to edit that email template through code...


please help me because it's very urgent.


mail templates are normal object so you can use apex/soql/dml to do that




ID templateID = '1231313123123'; // EmailTemplate ID: value could be from you selectlist in the page
EmailTemplate eml = [SELECT description from EmailTemplate where id =: templateID];
//fields to update
eml.description = 'test1';
update eml;



Thanks for your response.


But i need  :


  1. Select and insert an email template (including merge fields)
  2. Edit the email if needed before sending.