function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael2009Michael2009 

How to pass value into the merge field in the Email template

I am building a customized send email function with Visualforce page. If user chooses an Email template, in the email body(input text area), the merge field value {!Contact.Name} cant get the correct data as standard send email function can do. I am not sure if anyone has any solution to solve this problem, I will appreciate it.

 

What I am trying to do now is to create another temporary email with setTargetObjectId, setWhatId and setTemplateId, send the temporary email out and then use getPlainTextBody to get the temporary email body, in which all merge fields are replaced by the correct data. But the problem is the temporary email already sent out to the contact. So is there any way to re-direct the temporary email sent to a dummy address, not to the contact?

Cool_DevloperCool_Devloper

Mike,

I am sorry but I am thoroughly confused about what you are trying to exlpain here!

Can you please elaborate the scenario?

Cool_D

Michael2009Michael2009

Thanks for your reply. The scenario is I created a visualforce page to send email, just like standard send email page. When user choose a Email Template, there are some merge field like {!Contact.Name}  or {!Account.Email} in the Email Template can't be passed correct value like standard Send email function. 

 

So my question is how to pass the value to those merge field in the Visualforce page? Thanks

Cool_DevloperCool_Devloper
Well, i Just recollected, i could get the merge fields of the record which was set as the ObjectId but the relationship fields, won't be populated!

Cool_D 

Message Edited by Cool_Devloper on 12-18-2009 11:50 PM
sachin.ramdasisachin.ramdasi

Hi Michael2009

Did you get any solution for your problem? I'm facing the same issue, so curious about the solution

 

Thanks

Sachin