Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
createEmailTemplate(emailTemplateInput)
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.GenericResponseOutputRepresentation createEmailTemplate(ConnectApi.EmailTemplateInputRepresentation emailTemplateInput)
Parameters
- emailTemplateInput
- Type: ConnectApi.EmailTemplateInputRepresentation
- Input representation that contains the metadata for the email template. The fileId field is not accepted in this Apex representation.
Return Value
Example
1ConnectApi.EmailTemplateInput input = new ConnectApi.EmailTemplateInput();
2input.name = 'Sample Email Template';
3input.id = 'email-template-id';
4input.emailSubject = 'Email Subject';
5input.description = 'Email template description';
6input.contentDocumentId = '069SB0000047U0mYAE';
7input.activatedDate = Date.today();
8input.deactivatedDate = Date.today().addDays(365);
9input.senderType = 'SalesRep';
10input.senderEmailFieldAPIName = 'noreply@company.com';
11input.replyToType = 'SalesRep';
12input.replyToEmailAddress = 'support@company.com';
13input.bccEmailIdList = 'admin@company.com';
14input.isActive = true;
15input.isDefaultAutoEmailTemplate = false;
16input.isSubjectLineEditable = true;
17input.shouldIgnoreEmailConsent = false;
18input.surveyId = '0KdYH0000000VyH0AU';
19input.productId = '1KeYH0000001j2m0AA';
20input.communicationSubscriptionId = 'comm-sub-source-system-id';
21input.automatedEmailContextType = 'ProviderVisit';
22input.automatedEmailActionType = 'Create';
23input.languages = new List<String>();
24input.languages.add('es_AD');
25input.languages.add('es');
26input.topics = new List<String>();
27input.topics.add('Onboarding');
28input.topics.add('User Engagement');
29input.customFields = new List<ConnectApi.CustomFieldRepresentation>();
30ConnectApi.CustomFieldRepresentation customField1 = new ConnectApi.CustomFieldRepresentation();
31customField1.fieldName = 'Email_Template_Category__c';
32customField1.fieldValue = 'Product Information';
33input.customFields.add(customField1);
34ConnectApi.CustomFieldRepresentation customField2 = new ConnectApi.CustomFieldRepresentation();
35customField2.fieldName = 'Priority__c';
36customField2.fieldValue = 'High';
37input.customFields.add(customField2);
38System.debug(ConnectApi.LifeSciEmailTemplate.createEmailTemplate(input));