I'm comfortable with sending emails using APEX and using mailmerge within that process. What I want to do now is load an email template, mailmerge it automatically using a predetermined contact ID and then place the output in a WYSIWYG editor. After which I would like to be able to convert the WYSIWYG editor content into an email and send it.
For an example please look at /_ui/core/email/author/EmailAuthor, select a contact and then click the Select Template button and select a template. The template will be dropped in a WYSIWYG editor and then clicking Send will work.
I'm able to load an EmailTemplate's Body and place it in a WYSIWYG editor but then
- I don't have mailmerge fields populated.
- Setting the data from the WYSIWYG editor as the htmlValue of an Email throws an FIELD_INTEGRITY_EXCEPTION error when I attempt to send it because the WYSIWYG editor doesn't feed out the same format of data.