You need to sign in to do that
Don't have an account?
Pls confirm: Combining EmailTemplates - no way to automatically merge the template fields?
Hello community, another newbie question.
This is how far i got (the picture is almost up to date ;)):
- get a list from available templates from a certain directory
- add each selected template into editable textarea
- use the edited textarea as Email Body
- send the Email
What is obviously missing is the merging of the fields in the Email body.
I had a look on the SingleEmailMessage(); Documentation (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_sendemail.htm#SingleEmailMessage
and also on this post https://developer.salesforce.com/forums/ForumsMain?id=906F000000094ClIAI)
It seems to me that things are getting very, very tricky at this point, if its even possible at all: As I understood in order to merge the fields approriately, I need the templateId, whatId and TargetObjectId.
I got no problem with TargetObjectId. For WhatId it seems to be the case that might differ for each selected EmailTemplate, but if the merging of fields is really depenent on templateId, too - I can not think of any way to elegantly achieve the parsing of the templates - as I cannot provide the sendEmail method with different templateIds.
As my employer wants to be able to combine and edit templates on the fly (see screenshot), I was wondering if there is any way to achieve correct field merging without doing RegEx and stuff myself...
If there is no other way, please point me in the right direction - I am at loss.
Thank you for your input,
Sz