I need to convert 200 classic emailtemplates to lightning templates and I've encountered an obstacle. When I insert templates with lightning markup using SOQL and identical field values to an existing lightning template, they are saved as classic emailtemplates, with a folder name of "Unfiled Public Classic Email Templates" even though the folder has the same ID as existing Lightning templates. If I save a template using the default lightning rich text email editor, it saves with the same folder id but is now identified as a Lightning emailtemmplate in folder "Public Email Templates" if I view it by id. The template identified as classic, with lightning markup, opens in the classic template editor. The template identified as lightning opens in the lightning template editor.
There is only one difference that I can see between the two emailtemplate files. When I save an emailtemplate using the default lightning editor, salesforce appends an underscore and a number to the developerName as follows:
The process by which template types are differentiated doesn't apear to be documented anywhere. I would like know how to upload/insert an email template so that it saves as a lightning template and not a classic template.
Note that the lightning emailtemplate record page includes a field called "related entity type." This isn't a documented field on emailtemplate and it's not derived from the lightning merge codes, because there isn't a merge code for lead in that example. Is there another object where a whatId for the emailTemplate is stored?