You need to sign in to do that
Don't have an account?
sekhar maramreddy
how to create emailtemplate dynamically in salesforce through code
how to create emailtemplate dynamically in salesforce through code
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
- https://salesforce.stackexchange.com/questions/46371/dynamic-email-template-body
hope it will be helpful.Please mark it as best answer if the information is informative.
Thanks
Rahul Kumar
https://krishhari.wordpress.com/2013/09/03/dynamically-populating-custom-html-email-template-content-in-force-com-with-custom-dynamic-data-using-apex/
Hope it helps
I have gone through your question. You can create the email template dynamically through Apex Code.
The given below can be used for test class and if you want to use for a simple apex class remove the system.runAs(user) line.
Please go through the code given below.
public static String createEmailTemplate(){
EmailTemplate validEmailTemplate;
System.runAs (new User(Id = UserInfo.getUserId()) ){
validEmailTemplate = new EmailTemplate();
validEmailTemplate.isActive = true;
validEmailTemplate.Name = 'name';
validEmailTemplate.DeveloperName = 'unique_name_addSomethingSpecialHere';
validEmailTemplate.TemplateType = 'text';
validEmailTemplate.FolderId = UserInfo.getUserId();
insert validEmailTemplate;
}
return validEmailTemplate.ID;
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com