You need to sign in to do that
Don't have an account?
Sunay - KVP Bus Solns
Trigger to create standard HTML EmailTemplate
Hi,
Does anybody know how to create a HTML Email template using a trigger or Apex class. I have tried creating a EmailTemplate using trigger but it throws an Mixed DML exception.
I am not able to figure out the solution for the same.
Kindly give an solution ASAP.
You can't mix Setup and non-Setup DML operations. For example, you can't create a Salesforce user in a trigger and modify data. Instead, make your HTML creation code a @future operation so it runs asynchronously. If that won't work, then maybe you need to reconsider what you're trying to do-- maybe you don't need email templates at all.
Since we have a visual force Email Editor we need to save the template in standard Email Templates once the record is created as a custom object.
Can we create @future operations in a trigger???
You can call a future method from basically anywhere except another future method (see @future annotation in the docs). It works like this:
Your future method can then do additional stuff: